Jump to content
OmerAslan

[SOLVED] Adding New Page

Recommended Posts

Hello,

I wan to add new page on phpVMS 7. Is it possible? If it is, can someone explain how to do it?

Edited by OmerAslan
Solved

Share this post


Link to post
Share on other sites

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

@extends('app')
@section('title', 'About')

@section('content')
<!-- Content HTML goes here -->
<h3>Test</h3>
@endsection

Notes:

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');
})->name('about_page');

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×