The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Dynamic Header per Forum/Page
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 [DATE]1604391166[/DATE] at [TIME]1604391166[/TIME] --------------- Code:
<vb:if condition="$page['nodeid'] == 3"> |
#2
|
||||
|
||||
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). Code:
$safe_functions[] = 'rand'; https://www.youtube.com/watch?v=wShJ...=youtu.be&t=44 https://www.youtube.com/watch?v=wShJ...=youtu.be&t=60 https://www.youtube.com/watch?v=wShJ...youtu.be&t=124 https://www.youtube.com/watch?v=wShJ...youtu.be&t=180 Maybe a vB5 coder may help you more with this issue. |
Благодарность от: | ||
yilmaz |
#3
|
|||
|
|||
Quote:
Code:
<vb:if condition="!empty($page['nodeid']) AND !empty($page['channelid'])"> Your post is too unspecific. (for me) |
#4
|
||||
|
||||
Quote:
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 [DATE]1604412325[/DATE] at [TIME]1604412325[/TIME] --------------- 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. |
#5
|
||||
|
||||
Would you like to display the description of the forum in the place I marked as in the screenshot?
Or do you want to add a custom description to each forum, as in this screenshot? |
#6
|
||||
|
||||
<a href="https://vborg.vbsupport.ru/showthread.php?t=328380" target="_blank">Yilmaz - Channel Description Per Forum Page vB5</a>
|
#7
|
||||
|
||||
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: HTML 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> <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... |
#8
|
||||
|
||||
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... HTML Code:
{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> HTML Code:
{vb:raw headtitle} {vb:raw headdesc} 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. |
#9
|
||||
|
||||
Quote:
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. |
#10
|
||||
|
||||
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.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|