PDA

View Full Version : Code to show a template on only the front page


HM666
01-08-2015, 10:46 PM
I need to know how to have a custom template only show on the front page of the CMS. I have installed a custom slider on my vB 4.2.2 CMS using the widget system. The widget that I'm using has a custom template powering it. I need to know how to show that slider only on the front page of my CMS. Right now obviously it shows on all the CMS pages. :(

Link: http://lenmkaiser.com/vb/vb4/content.php

bridge2heyday
01-08-2015, 11:43 PM
You Can Try
<vb:if condition="$nodeid == 1"> </vb:if>
OR
<vb:if condition="(THIS_SCRIPT == 'vbcms' AND !$_GET['r'])"></vb:if>

HM666
01-09-2015, 12:01 AM
You Can Try
<vb:if condition="$nodeid == 1"> </vb:if>
OR
<vb:if condition="(THIS_SCRIPT == 'vbcms' AND !$_GET['r'])"></vb:if>

Thanks! EDIT: The second code worked.

bridge2heyday
01-09-2015, 12:06 AM
Thanks! So on the first one if I changed the nodeid to whatever nodeid a particular page is i can have the widget show on just that page?

Yes , it should appear in this node only .. if you want to show in multiple nodes you can use
<vb:if condition="in_array($nodeid,array(1, 2, 3))">

HM666
01-09-2015, 01:59 AM
I tried that and it did not show up. How do you find what the node id is? I thought it was the id of the link in the Navigation Manager but that did not work either. I tried it with nodeid of 1 and tried it with nodeid of 8 because the Navigation Menu had the id of the tab as 8.

HM666
02-02-2015, 11:59 PM
Anyone know why this first code does not work on a particular page?

<vb:if condition="$nodeid == 1"> </vb:if>

I have tried several different ID numbers to replace the 1 but nothing works and it is not showing on the page. Where do I find the nodeid of a page? Is it the number that shows in the friendly URL? Or is it the tab number? I've tried both in that space and neither work in that code above.

John Lester
02-03-2015, 07:45 AM
Try this for the CMS home page:


{vb:raw $vbulletin->parentnode}


The page at the end of the post says the node id is the number after the 'r='

content.php?r=116-my-phpcontent.php/116-my-php
http://www.estetica-design-forum.com/entry.php?745-Create-a-custom-PHP-page-in-vBulliten-4-CMS

HM666
02-05-2015, 11:28 PM
Try this for the CMS home page:


{vb:raw $vbulletin->parentnode}


The page at the end of the post says the node id is the number after the 'r='

content.php?r=116-my-phpcontent.php/116-my-php
http://www.estetica-design-forum.com/entry.php?745-Create-a-custom-PHP-page-in-vBulliten-4-CMS


Ok I do not want it to show on the home page though. I want it to show on the nodeid page 114 only and no where else, what code do I use for that? I've tried all the code above and variations of those and nothing has worked. I've made a slider widget and I want it to only show on one page. The code for the template of the widget is:

<vb:if condition="(THIS_SCRIPT == 'vbcms' AND !$_GET['r'])"><div class="cms_slider">{vb:raw static_html}</div></vb:if>

That code will show it only on the front page, but I want to move it to show only on the nodeid page of 114. How do I do that?

John Lester
02-06-2015, 06:25 PM
Have you tried?


<vb:if condition="(THIS_SCRIPT == 'vbcms' AND !$_GET['r=114'])"><div class="cms_slider">{vb:raw static_html}</div></vb:if>

HM666
02-07-2015, 06:11 AM
Have you tried?


<vb:if condition="(THIS_SCRIPT == 'vbcms' AND !$_GET['r=114'])"><div class="cms_slider">{vb:raw static_html}</div></vb:if>


Yes and that shows it on the correct page but it also shows it on the home page (front page) as well though. I'd rather take it off the front page.

John Lester
02-07-2015, 06:50 AM
Ok I'm not great with code, so these ideas will need some polish :D

Have you tried using double ='s ... r==114? What about another AND clause that blocks it from parentnode?

If an AND clause won't work, perhaps a vbelse? E.G. <vb :else>if r=parentnode don't display </ vb:else>

I haven't actually looked at vBulletin code in awhile, I'm struggling with my "advanced" programming class and visual basic :o

HM666
02-07-2015, 08:05 PM
Tried the double = signs that did not work either. As for the other I do not know how to do that. I'm not a PHP programmer I code HTML & CSS and that is the extent of it. So I do not know a lot about the PHP codes. I know some but not enough to be able to create code from scratch.

kh99
02-07-2015, 08:35 PM
I don't know if that code is the right way to do it or not, but I think you'd want this:
<vb:if condition="(THIS_SCRIPT == 'vbcms') AND ($_GET['r'] != 114)"><div class="cms_slider">{vb:raw static_html}</div></vb:if>

HM666
02-07-2015, 08:45 PM
I don't know if that code is the right way to do it or not, but I think you'd want this:
<vb:if condition="(THIS_SCRIPT == 'vbcms') AND ($_GET['r'] != 114)"><div class="cms_slider">{vb:raw static_html}</div></vb:if>

That only shows on the front page. I want it to only show on the 114 page. :(

kh99
02-07-2015, 08:46 PM
OK, try changing it to $_GET['r'] == 114 . But like I said, I don't know if that's the way to do it, I'm just trying to fix the posted code, because I don't think $_GET['r==114'] was right.

John Lester
02-08-2015, 01:03 AM
If that doesn't work then a shot in the dark here might :D

before the AND in the previous code from kh99 ...

AND ($_GET['r'] != parentnode)
So full code would be:

<vb:if condition="(THIS_SCRIPT == 'vbcms') AND ($_GET['r'] != parentnode) AND ($_GET['r'] != 114)"><div class="cms_slider">{vb:raw static_html}</div></vb:if>

HM666
02-08-2015, 07:59 AM
Thanks but that only shows on the front page too. :( on both of those. :(

Dead Eddie
02-08-2015, 10:44 AM
<vb:if condition="$_GET['r']==114"></vb:if>

John Lester
02-08-2015, 05:43 PM
<vb:if condition="$_GET['r']==114"></vb:if>

Yea I can see that working since it's not referring to "this script".

HM666
02-09-2015, 12:57 AM
<vb:if condition="$_GET['r']==114"></vb:if>

YAY! All hail Dead Eddie! Thanks that worked :)

Dead Eddie
02-09-2015, 01:30 AM
Glad it worked for you.