Join our Facebook Group
ScriptsTribe • Sngine • Community
Join

Forums

The great place to discuss topics with other users

How to create a Dynamic Page instead of Static page

'
Join the Conversation Publier la réponse
Jane Marcia
Admin
Joined: 2025-05-17 02:14:16
2025-05-22 02:06:47

thank you

Richard  Wing
Admin
Joined: 2025-01-18 19:22:40
2025-05-22 02:42:12

So! have been asked how we can create a Dynamic Page in Sngine so let's go

What is a Dynamic page? Dirent from the static page you create via admincp, by creating a dynamic page you can skip the static/page url and add php logic to it.

First you will create a folder inside modules/YourFolderName

we do like this because we want to keep things organized and separated from sngine files so things does not get confusing late... 

So here I will create a page called My News inside my folder modules/mynews/index.php

and content/themes/default/templates/mynews/index.tpl

before I visit this page, I will add it to my htaccess file like this 

 

RewriteRule ^mynews/?$ modules/mynews/index.php [QSA,L]


Now I will open the modules/mynews/index.php and add code like this (now pay attention to the comments inside the code)

<?php// fetch bootloader and connects to database
require('../bootloader.php');

// This is a page for admin, no admin will be redirected to index page, if you want this page for regular user, remove this code
if (!$user->_is_admin) {
   redirect();
}

// This code allows access to page only if user is logged in Redirect guests
if (!$user->_logged_in) {
  user_access();
}

// This bit adds refferer url to the url
    referer_url();

//If you want to add any php logic, it will be placed here in between
// this defines the page header and title
page_header(__("My News") . ' | ' . __($system['system_title']));

// this defines the page footer, note it is assigning the tpl inside the template folder
page_footer('mynews/index');

Now we are going to work the tpl file that we added to the template folder earlier,
open content/themes/default/templates/mynews/index.tpl

Inside that add

{include file='_head.tpl'}
{include file='_header.tpl'}

your custom code here, e.g
 <div class="card mt10">
    <div class="card-header bg-success text-white">
    <i class="fa fa-check-circle mr5"></i> {__("My News Block")}
    </div>
    <div class="card-body">
   
My News goes here
    </div>
</div>

{include file='_footer.tpl'}

and now you will be able to visit your page at yoursite.com/mynews

you can add more pages inside that same folder, e.g mynews/whaisnew

just replace the mynews/index with mynews/whaisnew everywhere that is necessary, rinse and repeat.

Hope this tutorial is userfull. Enjoy

David  Santos
Member
Joined: 2024-11-24 02:22:14
2025-05-25 07:18:16

So! have been asked how we can create a Dynamic Page in Sngine so let's go

What is a Dynamic page? Dirent from the static page you create via admincp, by creating a dynamic page you can skip the static/page url and add php logic to it.

First you will create a folder inside modules/YourFolderName

we do like this because we want to keep things organized and separated from sngine files so things does not get confusing late... 

So here I will create a page called My News inside my folder modules/mynews/index.php

and content/themes/default/templates/mynews/index.tpl

before I visit this page, I will add it to my htaccess file like this 

 

RewriteRule ^mynews/?$ modules/mynews/index.php [QSA,L]


Now I will open the modules/mynews/index.php and add code like this (now pay attention to the comments inside the code)

<?php// fetch bootloader and connects to database
require('../bootloader.php');

// This is a page for admin, no admin will be redirected to index page, if you want this page for regular user, remove this code
if (!$user->_is_admin) {
   redirect();
}

// This code allows access to page only if user is logged in Redirect guests
if (!$user->_logged_in) {
  user_access();
}

// This bit adds refferer url to the url
    referer_url();

//If you want to add any php logic, it will be placed here in between
// this defines the page header and title
page_header(__("My News") . ' | ' . __($system['system_title']));

// this defines the page footer, note it is assigning the tpl inside the template folder
page_footer('mynews/index');

Now we are going to work the tpl file that we added to the template folder earlier,
open content/themes/default/templates/mynews/index.tpl

Inside that add

{include file='_head.tpl'}
{include file='_header.tpl'}

your custom code here, e.g
 <div class="card mt10">
    <div class="card-header bg-success text-white">
    <i class="fa fa-check-circle mr5"></i> {__("My News Block")}
    </div>
    <div class="card-body">
   
My News goes here
    </div>
</div>

{include file='_footer.tpl'}

and now you will be able to visit your page at yoursite.com/mynews

you can add more pages inside that same folder, e.g mynews/whaisnew

just replace the mynews/index with mynews/whaisnew everywhere that is necessary, rinse and repeat.

Hope this tutorial is userfull. Enjoy

ScriptsTribe https://scriptstribe.com