This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello
At the moment I am trying to add projects to my website and I have difficulty understanding the backend & documentation. Bear with me I have a basic understanding of MVC (been following courses on treehouse and laracasts) and I'm sorry for the lack of structure in this post.
For my website I just want to be able to add projects in the backend and on the frontend view the latest projects i've been working on. for the backend I want an overview of these projects (real simple probably in a table or something akin) and then an add page(form). I assessed that a backend form is needed (for adding projects) with like basic details and that I need controller for routing, and maybe a component for displaying it on the frontend.
- name
- thumb_nail
summary link_url
Plugin file (tvanderv/projects/Plugin.php)
``<?php namespace Tvanderv\Projects;
use Backend; use System\Classes\PluginBase; use Controllers;
class Plugin extends PluginBase { public function pluginDetails(){ return [ 'name' => 'Personal Projects', 'description' => 'Voeg projecten toe aan de database', 'author' => 'USERNAME' 'icon' => 'icon-list', 'homepage' => 'http://github.com/test/' ]; }
/*public function registerComponents(){
return [
'tvanderv/projects/components/index' => 'projectsIndex',
'tvanderv/projects/components/add' => 'addProjects',
'tvanderv/projects/components/overview' => 'projectsOverview'
];
}*/
public function registerNavigation(){
return [
'label' => 'Project',
'icon' => 'icon-check',
'url' => Backend::url('tvanderv/projects/projects')
];
}
public function boot() {
//what do i pass in here?
} }``
Projects.php(tvanderv\projects\controllers\Projects.php -> has a submap called projects (lowercase))
``<?php namespace Tvanderv\Projects\Controllers;
use Schema; use \Backend\Classes\Controller;
class Projects extends Controller {
/**
* Return index view
* And checks if database has a table called projects
*/
public function index() {
if (Schema::hasTable('projects')) {
$projects = DB::table('projects')->get();
foreach($projects as $projectItem) {
echo $projectItem;
}
}
else {
echo "No projects table found. Creating new table";
Schema::create('projects', function ($table) {
$table->increments('id');
$table->string('Naam', 60);
$table->string('Beschrijving');
});
}
}
}``
for the example above i'd think it would query the database and if not then add a table to the database. Perhaps it would be better to handle data in a model but i'm fairly new to MVC.
For the forms I came across this Backend form controller but I'm still unsure on how to knit everything together. What is the best way to make a add projects form, an overview page and then pass data into a component which I can call within a page.
Kind regards
Last updated
1-1 of 1