View Full Version : Dynamic Header per Forum/Page
Pitman
11-03-2020, 04:10 AM
I am wanting to dynamically change the header depending on what forum a user is viewing.
Can anyone help me get started with something like that? :)
--------------- Added 1604391166 at 1604391166 ---------------
<vb:if condition="$page['nodeid'] == 3">
Seems to work fine when looking at the specific forum id, but is there any way to pull the nodeid or forumid in the header template when viewing a thread/post within a certain forum?
lange
11-03-2020, 06:54 AM
With vB 3.8.11, I am using conditionals with the following PHP module to dynamically change all page content including the header.
I am not a coder and I am not familiar with conditionals in vB5 Connect (it would be a good idea to have a list of conditionals under vB 5 Connect).
$safe_functions[] = 'rand';You can see the dynamique change in action here (sorry it's in my first language):
https://www.youtube.com/watch?v=wShJtg0R330&feature=youtu.be&t=44
https://www.youtube.com/watch?v=wShJtg0R330&feature=youtu.be&t=60
https://www.youtube.com/watch?v=wShJtg0R330&feature=youtu.be&t=124
https://www.youtube.com/watch?v=wShJtg0R330&feature=youtu.be&t=180
Maybe a vB5 coder may help you more with this issue.
Seems to work fine when looking at the specific forum id, but is there any way to pull the nodeid or forumid in the header template when viewing a thread/post within a certain forum?
As you wrote they are always inside. But you have to check if empty or not. Like line 31
<vb:if condition="!empty($page['nodeid']) AND !empty($page['channelid'])">
Or do you mean how you get (in your example the "3") the list of nodeid's or channelid's to compare with? How do you want do manage this values? In admincp, as a value in settings/options? As a channel setting? As a fixed list? What is the 'dynamic content'?
Your post is too unspecific. (for me)
Pitman
11-03-2020, 11:54 AM
As you wrote they are always inside. But you have to check if empty or not. Like line 31
<vb:if condition="!empty($page['nodeid']) AND !empty($page['channelid'])">
Or do you mean how you get (in your example the "3") the list of nodeid's or channelid's to compare with? How do you want do manage this values? In admincp, as a value in settings/options? As a channel setting? As a fixed list? What is the 'dynamic content'?
Your post is too unspecific. (for me)Thanks for the response...
Basically, what I'm trying to do is display the forum title and a brief description (not the same exact description of the forum) within the header template of each forum\thread page.
For example... the header on this site: it has an image that says VBULLETIN.ORG then "The Official vBulletin Modifications Site." Doing what I'm trying to do here on this site, would change the image to the text "vB5 Programming Discussions" and then beneath it, a custom description of the forum this thread is in (instead of "Discuss anything related to programming for vBulletin 5.x series eg. PHP, MYSQL, XHTML, etc", something like "Programming modifications and customizations for vBulletin 5.x series" just for example).
I basically want to mimic the forum title\description text below the navigation bar inside of the header template, but use a secondary description for each forum\main page.
I hope that makes a little better sense. :)
--------------- Added 1604412325 at 1604412325 ---------------
How do you want do manage this values? In admincp, as a value in settings/options? As a channel setting? As a fixed list?Honestly, in 4.x, I did this all inside the header template. I would, however, love to be able to add a secondary description field for each forum inside the admincp to be able to control this content easier, but that's not 100% necessary. I can use if\else conditions in the header template as I did previously... I don't intend to add\change forums very frequently.
yilmaz
11-27-2020, 05:23 AM
Would you like to display the description of the forum in the place I marked as in the screenshot?
https://vborg.vbsupport.ru/attachment.php?attachmentid=158047&stc=1&d=1606461711
Or do you want to add a custom description to each forum, as in this screenshot?
https://vborg.vbsupport.ru/attachment.php?attachmentid=158048&stc=1&d=1606461711
yilmaz
11-29-2020, 03:19 AM
<a href="https://vborg.vbsupport.ru/showthread.php?t=328380" target="_blank">Yilmaz - Channel Description Per Forum Page vB5</a>
delicjous
11-30-2020, 03:23 AM
Sorry just read your question...The last answer you got is not the best.
An addon could help, but there is also an easier way with less performance issues.
1. Create phrases for each channel you need a new description and name it
... whateveryouwant_1 -> this have to be whateveryouwant_channelnumber for each channel.
If you want a description in channel 3, 12 and 23 you need the templates
whateveryouwant_3, whateveryouwant_12, whateveryouwant_23
2. Create a template and hook it into the position you need. You could see hook positions when you activate the options in (options.php?do=options&dogroup=plugin) for admins only.
3. In the template you need the following code:
<vb:if condition="in_array($page['channelid'], array(3,12,23)">
{vb:set dcdphrasename, 'whateveryouwant_'}
{vb:strcat dcdphrasename, {vb:raw page.channelid}}
{vb:phrase dcdphrasename}
</vb:if>
If that description should show at channelview only you need to replace the condition:
<vb:if condition="in_array($page['channelid'], array(3,12,23) AND $page['channelid'] == $page['nodeid']">
Thats it... (Not testet, but should work) ... (some hook-positions (eg header before notices) needs more code to look nice and clean!)
Everytime you need a new description you create a new phrase and paste the channelid into the array on that template. The array in the condition takes care the description only loads on pages you it it loaded. first two lines in condition build the phrasename and the third ffetches and display the phrase.
The reson I would not use an entire addon with a new content-editor for this, is the performance-loss each new addon or plugin means for your page. Phrases are cached and your admin do not need a new content-editor to use it. The addon set a new field to a databasetable and have to fetch this each time a user is view a channel-page, even there is no desription on it.... There is so much more...
Pitman
11-30-2020, 06:06 AM
Thanks delicjous, that actually sounds simple enough... I've been able to accomplish everything I've needed to do so far with editing the header template (and even the display_Forums_list template for a few other things)... however, now you've got me concerned about performance issues...
Would your suggestion use less resources than using something similar to...
{vb:set headtitle, {vb:raw page.title}}
{vb:set headdesc, 'Default Extended Description'}
<vb:if condition="$page['channelid'] == 24">
{vb:set headtitle, 'Channel 24 Extended Title'}
{vb:set headdesc, 'Channel 24 Extended Description'}
<vb:elseif condition="$page['channelid'] == 18" />
{vb:set headtitle, 'Channel 18 Extended Title'}
{vb:set headdesc, 'Channel 18 Extended Description'}
<vb:elseif condition="$page['channelid'] == 16" />
{vb:set headtitle, 'Channel 16 Extended Title'}
{vb:set headdesc, 'Channel 16 Extended Description'}
................................
</vb:if>
{vb:raw headtitle}
{vb:raw headdesc}
--------------- Added 1606724368 at 1606724368 ---------------
Although I'm not a coder or anything, it seems like to me if there could be an extra column added to the database table for each forum\channel (whatever) for a more descriptive title and description (not to mention breadcrumb title). It would be a lot easier for me to do what I need to do and possibly less resource intensive.
delicjous
11-30-2020, 06:51 AM
Thanks delicjous, that actually sounds simple enough... I've been able to accomplish everything I've needed to do so far with editing the header template (and even the display_Forums_list template for a few other things)... however, now you've got me concerned about performance issues...
Would your suggestion use less resources than using something similar to...
{vb:set headtitle, {vb:raw page.title}}
{vb:set headdesc, 'Default Extended Description'}
<vb:if condition="$page['channelid'] == 24">
{vb:set headtitle, 'Channel 24 Extended Title'}
{vb:set headdesc, 'Channel 24 Extended Description'}
<vb:elseif condition="$page['channelid'] == 18" />
{vb:set headtitle, 'Channel 18 Extended Title'}
{vb:set headdesc, 'Channel 18 Extended Description'}
<vb:elseif condition="$page['channelid'] == 16" />
{vb:set headtitle, 'Channel 16 Extended Title'}
{vb:set headdesc, 'Channel 16 Extended Description'}
................................
</vb:if>
{vb:raw headtitle}
{vb:raw headdesc}
--------------- Added 1606724368 at 1606724368 ---------------
Although I'm not a coder or anything, it seems like to me if there could be an extra column added to the database table for each forum\channel (whatever) for a more descriptive title and description (not to mention breadcrumb title). It would be a lot easier for me to do what I need to do and possibly less resource intensive.
First you use multiple if statements, which could be done with only one if you use an array.
Each if-condition needs performance (not that much, but you should use one if you could)!
Second you should use template-hooks to show any of your custom-content. The templates try to merge all your custom-stuff on updates. If this fails you use the old core-template and that could break your page in worst case. Just search for hook in the header template and you could see the locations in the template.
Pitman
11-30-2020, 07:02 AM
Honestly, I'm not too up-to-date on template hooks, but it looks like I could possibly use the hook "{vb:hook 'header_after_body_begin'}" for that. I'm still not sure what the best way to go about this would be.
delicjous
11-30-2020, 07:10 AM
Some links might helpful for you:
https://forum.vbulletin.com/blogs/wayne-luke/3929999-
https://forum.vbulletin.com/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4425473-how-to-affect-variables-in-template-hooks
https://forum.vbulletin.com/blogs/joe-d/3932614-
https://www.vbulletin.com/docs/html/main/dev_vbulletin5_template_syntax
And like I wrote before ... you have the ability to show the hook places directly on viewing your page. there are options for that in settings -> options -> plugins
yilmaz
11-30-2020, 02:36 PM
This mode shows the meta description to the right of the logo in the header
Meta Description in Header (https://vborg.vbsupport.ru/showthread.php?t=328383)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.