Jump to content

[SOLVED] Adding New Page


Recommended Posts

If it's just a static page then yes it's possible (if it's dynamic, as in it requires a lot of database activity/a lot of methods then it's best put through a controller/module)

For this, I'll just create a static about page

1. Go to resources/views/layouts/default (unless you have another layout, then put it in there)

2. Create a new folder called 'about'

3. Create a new file inside this folder called 'index.blade.php'

4. Inside this file place this

@section('title', 'About')

<!-- Content HTML goes here -->


The @extends('app') means that this page will be extending off the master template called 'app.blade.php' which is found in the resources/views/layouts/default folder

The @section('title', 'About') means that (because it is set by the @yield('title') in the master template) this will show up in the <title></title> of the browser tab. In this case we've set it to 'About'.

The @section('content') is where you put your normal HTML for your page (this is also set in the master template)

5. Routing

Go to app/Routes/web.php and find this line (around line 17)

Route::get('livemap', 'AcarsController@index')->name('livemap.index');

The ::get means you are submitting a GET HTTP request to the url '/livemap' (note this can be inside a prefix)

The 'AcarsController@index' means you are targeting the 'index' method (function) of the AcarsController controller

The  ->name('livemap.index'); is giving this route a unique name (in this case 'livemap.index') and can be referred to in the app via route('livemap.index')


After this line, place this

Route::get('about', function() {
	return view('layouts.default.about.index');

Where the view file being targeted is located in resources/views/layouts/default/about/index.blade.php (hence the layouts.default.about.index)

The principles are the same, but it's using a 'Closure' (the function() bit) instead of passing it through a controller, because it is just a static page and there are no other methods being used, this is sufficient.

6. Go to {http://yourvaurl.com}/about and it should show up.


Final notes:

I suggest you read the docs over at http://docs.phpvms.net/customizing and also the laravel blade docs over at https://laravel.com/docs/master/blade to get used to the new templating system.

When updating the phpVMS version you may lose this work, so for that reason I recommend making a module or widget. Most of the principles are the same in terms of the actual templating but the routing won't affect the default files (instead it is put inside the module). Check out the docs here http://docs.phpvms.net/developers/add-ons-and-modules for info about that.

If there are multiple pages you want added, you could make a module that contains all of them (either by storing the HTML in the database or by routing the templates through a controller) which would be easier than making a module for each page.

Edited by web541
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...