![]() |
Using vb:raw in templates
Hi, I have create multiple custom pages on my forum. I have a navigation bar on the left of all of said pages. Everytime I add/change a link, I need to go into each and every template to add/change that link.
Is there a way to make a template called "custom_nav", add the links for my nav bar, then call that template from each of the custom pages? If so, can someone help me do it or show me where to start please? Thanks |
You could use a template. You would need php code to render your template and save the results in a variable, then register that variable to any template where you want to display it. You could do that in a plugin, or if your custom pages are php scripts, you could do it in your custom scripts.
How are your custom pages implemented? |
|
Quote:
I have this in my php file. Code:
<?php So, I have a template called "siterules", using the PHP file above. I now want to add a navigation bar on this page and a further 4 pages so when I add/change a link, it reflects on all pages. How can I use a plugin to pull the template "navigation" and insert it on each of the custom pages? |
Well, since you have custom php files you don't need to use a plugin. You can add code to render your custom template before the "main" page template. So just after the "YOUR CUSTOM CODE GOES HERE", add something like:
Code:
$templater = vB_Template::create('custom_nav'); Then lower down, add a "register" line to your template code: Code:
$templater->register('custom_nav', $custom_nav); One last thing, for efficiency: add custom_nav to the (existing) array of templates to cache ($globaltemplates): Code:
$globaltemplates = array('siterules', 'custom_nav'); |
Thanks. I will try that and report back.
--------------- Added [DATE]1409309336[/DATE] at [TIME]1409309336[/TIME] --------------- Quote:
I have one other question. How do I make a page show if there is no Code:
if ($_REQUEST['do'] == BLAH Code:
if ($_REQUEST['do'] == 1 |
As a rule: You never, ever once address URL parameters directly like that. Opens you up for all kinds of vulnerabilities.
Read and implement: https://vborg.vbsupport.ru/showthread.php?t=119372 After that, you will have your parameter in a nice variable, for example: do. And to your question - if a variable is not defined, you define it in your code. See PHP man isset. Along the lines of Code:
if (!isset($do)) Code:
if (!isset($do) OR $do == 1)) |
So I could do this:
Code:
if (!isset($do) OR $_REQUEST['do'] == 1) |
Why would you use $_Request again if you have cleaned the input and assigned it to $do? If you havn't done that, $do will not work. And as I said before: Accessing $_REQUEST directly is evil. Do not do it. Read the link I gave you.
This is really basic PHP 101. |
Quote:
|
All times are GMT. The time now is 06:43 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|