Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 27 Aug 2014, 10:24
Black Snow Black Snow is offline
 
Join Date: Jul 2012
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
Reply With Quote
  #2  
Old 27 Aug 2014, 10:40
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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?
Reply With Quote
  #3  
Old 27 Aug 2014, 11:31
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
See http://www.vbulletin.org/forum/showthread.php?t=228078
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #4  
Old 27 Aug 2014, 12:26
Black Snow Black Snow is offline
 
Join Date: Jul 2012
Originally Posted by kh99 View Post
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?
The pages are done using templates. I followed an article on here for creating custom pages using templates.

I have this in my php file.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I think this is all I need in the PHP file.

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?

Last edited by Black Snow; 27 Aug 2014 at 14:55.
Reply With Quote
  #5  
Old 27 Aug 2014, 15:14
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Then lower down, add a "register" line to your template code:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

then you should be able to put {vb:raw custom_nav} in your siterules template where you want it to appear.

One last thing, for efficiency: add custom_nav to the (existing) array of templates to cache ($globaltemplates):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #6  
Old 29 Aug 2014, 09:26
Black Snow Black Snow is offline
 
Join Date: Jul 2012
Thanks. I will try that and report back.

--------------- Added 29 Aug 2014 at 10:48 ---------------

Originally Posted by kh99 View Post
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Then lower down, add a "register" line to your template code:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

then you should be able to put {vb:raw custom_nav} in your siterules template where you want it to appear.

One last thing, for efficiency: add custom_nav to the (existing) array of templates to cache ($globaltemplates):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Worked a treat! thank you very much.

I have one other question. How do I make a page show if there is no

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I have my pages now set up:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

But how do I get page 1 to show if someone goes to http://site.com/info.php
Reply With Quote
  #7  
Old 29 Aug 2014, 12:39
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
As a rule: You never, ever once address URL parameters directly like that. Opens you up for all kinds of vulnerabilities.

Read and implement: http://www.vbulletin.org/forum/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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Or do

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de

Last edited by cellarius; 29 Aug 2014 at 12:44.
Reply With Quote
  #8  
Old 29 Aug 2014, 16:43
Black Snow Black Snow is offline
 
Join Date: Jul 2012
So I could do this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #9  
Old 29 Aug 2014, 20:32
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
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.
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #10  
Old 30 Aug 2014, 13:05
Black Snow Black Snow is offline
 
Join Date: Jul 2012
Originally Posted by cellarius View Post
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.
Your link doesn't show how to use $vbulletin->input->clean_array_gpc when requesting a page. Could you show me an example?
Reply With Quote
  #11  
Old 30 Aug 2014, 14:50
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #12  
Old 30 Aug 2014, 15:22
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
Originally Posted by Black Snow View Post
Your link doesn't show how to use $vbulletin->input->clean_array_gpc when requesting a page. Could you show me an example?
Of course it does.

Cleaning Superglobal Arrays

By Superglobal, I mean $_POST, $_GET, $_REQUEST and so on. These arrays are created automaticly by PHP and contain the user-sent input. They are referenced in the vBulletin Input Cleaner by nice short single letter names. These are:
p - $_POST
g - $_GET
r - $_REQUEST
s - $_SERVER
e - $_ENV
c - $_COOKIE
f - $_FILES
and so on.
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #13  
Old 01 Sep 2014, 11:53
Black Snow Black Snow is offline
 
Join Date: Jul 2012
Originally Posted by Scanu View Post
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Thanks for the example. Makes me understand more now.

--------------- Added 02 Sep 2014 at 08:21 ---------------

Originally Posted by Scanu View Post
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
I tried doing this but it won't work if I access the info.php page without the query on the end of the URL:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by Black Snow; 02 Sep 2014 at 08:28.
Reply With Quote
  #14  
Old 02 Sep 2014, 13:11
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Originally Posted by Black Snow View Post
Thanks for the example. Makes me understand more now.

--------------- Added 02 Sep 2014 at 08:21 ---------------


I tried doing this but it won't work if I access the info.php page without the query on the end of the URL:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Try replacing this

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

With this

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #15  
Old 02 Sep 2014, 13:45
Black Snow Black Snow is offline
 
Join Date: Jul 2012
Originally Posted by Scanu View Post
Try replacing this

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

With this

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Thanks for helping. I still get a blank page.
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced Templates: Dynamic Templates Changing according to different conditions Logician vBulletin 2.x Full Releases 312 24 Apr 2005 19:20



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 22:04.

Layout Options | Width: Wide Color: