View Full Version : $forumid variable in $Globals for postbit,forumdisplay,forumhome,headerinclude,navba r
cellow
02-07-2013, 12:03 PM
Hi,
our forum get monthly new subforums. and at the moment we define where and to who we will show our ads (which are located in postbit_legacy, forumhome, forumdisplay, showthread, header, headerinclude, footer, navbar templates) by template conditionals.
but everytime a new subforum created we have to update the array $GLOBALS['forumid'] all conditionals with the new forumid.
1.
to save time, we are thinking of adding a "$show_ads_forumid_variable" to somewhere and use it the conditionals, so we dont need always to update all conditionals with the new forumid.
2.
we put in the forum-options (forum-manager) a field like "show ads (yes/no)", so all templates in this forum will not show the ads if no-> selected....
i will be happy, when somebody could help me with this issue out, i am also will to pay for it...
thank for you...
You could create a plugin using hook location parse_templates and code something like this:
global $show, $forumid;
if (isset($forumid) AND in_array($forumid, array(1, 2, 3)))
{
$show['ads_forumid_variable'] = 1;
}
then change all your template conditions to be:
<if condition="$show['ads_forumid_variable']">
if you wanted to get fancy you could make the forum list a field in the settings, or you could even make it an option when creating a forum.
cellow
02-07-2013, 01:19 PM
Thank you Kevin.
a) work this plugin also with conditions in postbit_legacy template?
b) in forums with the forumid 1, 2, 3, the ad will shown or not shown, if i use <if condition="$show['ads_forumid_variable']"> in the postbit_legacy template
Thank you Kevin.
a) work this plugin also with conditions in postbit_legacy template?
I haven't tried it, but I thought it would. Are you asking because it doesn't work in postbit_legacy?
b) in forums with the forumid 1, 2, 3, the ad will shown or not shown, if i use <if condition="$show['ads_forumid_variable']"> in the postbit_legacy template
It should show the ads in forumid 1, 2, 3.
cellow
02-07-2013, 01:26 PM
ah ok, so if i wouldnt like to show, i should use
global $show, $forumid;
if (isset($forumid) AND !in_array($forumid, array(1, 2, 3)))
{
$show['ads_forumid_variable'] = 1;
}
so the ad will not shown in forumids 1,2,3 ....
curiously the ads also not shown in forumhome ... although i just give some forumids in the plugin...
postbit_legacy doesnt work :(
I think froumhome does not have an associated forumid, so if you want them to show in forumhome, maybe try this:
global $show, $forumid;
if (!isset($forumid) OR !in_array($forumid, array(1, 2, 3)))
{
$show['ads_forumid_variable'] = 1;
}
I'm not sure why it wouldn't work in postbit_legacy. What did you have in that template before?
cellow
02-07-2013, 01:38 PM
my aim is the set the forumids in the plugin where i dont want to show the ads... so how my final plugin code should look like, if i use <if condition="$show['ads_forumid_variable']"></if> in the templates...
in postbit_legacy it worked before only if i used just 1 forumid like "$forumid != 3" but with arrays never worked for me ...
i tried:
$thread['forumid']
$GLOBALS['forumid']
$foruminfo['forumid']
$forum['forumid']
:((
I think you should be able to use the same condition (checking $show[''ads_forumid_variable']) in all places, if the plugin code is correct. It seems like it should work even in postbit_legacy.
I tested this: using hook parse_templates and this code:
global $show, $forumid;
if (!isset($forumid) OR !in_array($forumid, array(1, 3, 4)))
{
$show['ads_forumid_variable'] = 1;
}
Then in postbit_legacy template I have:
<if condition="$show['ads_forumid_variable']">
Show Ads!!!
</if>
and I find that the "Show Ads!" appears in forum 2 but not in others.
cellow
02-07-2013, 02:32 PM
thanks kevin for ur support so far!
it works with all other templates beside postbit_legacy...
i have this condition:
<if condition="(($post[postcount] % $vboptions[maxposts] == 1)) AND ($show['member']) AND $show['ads_forumid_variable']">
usually it should show for members who are not visiting the forum (ids in plugin) in the first post an ad.
but it doesnt...
i allready disabled and flushed all caching stuff (xcache,etc..)
maybe there is a correlation within other plugins? i select "1" as "order" for your plugin ... but it doesnt help...
i used andreas, template modification system which hooks starts at "template_compile" ... maybe this makes the problem?
is there any other location where i can hook your plugin?
Simon Lloyd
02-07-2013, 03:17 PM
I've created this https://vborg.vbsupport.ru/showthread.php?t=286403 which may help, really simple and does the job (pretty much) :)
is there any other location where i can hook your plugin?
I suppose it could be the template modification system. Try using hook global_start instead.
I've created this https://vborg.vbsupport.ru/showthread.php?t=286403 which may help, really simple and does the job (pretty much) :)
That's pretty good, but I couldn't see where it lets you do it by forumid.
Simon Lloyd
02-07-2013, 04:11 PM
Lol, i hadn't built that in (but i could do) as the person that comissioned it didnt need that, but it has the ability to put seperate variables in different forums, the ads dont show if you dont add the variable.
I suppose i could extend it to add the variable depending on forum selection, may be a little while as i dont have a lot of time at the moment.
Oh, I see - that could be used by making one of the variables a list of forums, then using that in a conditional, so it would allow you to edit the list in the settings instead of having to go to a plugin. Yeah, seems like that would work.
Simon Lloyd
02-07-2013, 05:15 PM
Oh, I see - that could be used by making one of the variables a list of forums, then using that in a conditional, so it would allow you to edit the list in the settings instead of having to go to a plugin. Yeah, seems like that would work.Lol, now thats thinking out of the box! :) i wouldn't have thought of it as easy as that!
cellow
02-07-2013, 07:32 PM
so how can i solve my problem with Simon Lloyd mod ??? i didnt really get what u guys talking about...
@kh99
even global_start hook didnt work :(
Well, you'd have to convert a string of number to an array then use it in an in_array(). But reading what you psted above, it wasn't working using the in_array() condition so there's got to be some other problem with your condition. If you use the plugin code and this condition do you see ads?
<if condition="(($post[postcount] % $vboptions[maxposts] == 1)) AND ($show['member']) AND 1">
cellow
02-07-2013, 08:41 PM
hmmm, very weird...
i tried:
<if condition="(($post[postcount] % $vboptions[maxposts] == 1))
ads here
</if>
even then, i dont see ads inside the postbit
it still saves somewhere my old conditions, because for "guests" the ads are shown, but not for members...
Maybe that's just a typo, but try this:
<if condition="($post[postcount] % $vboptions[maxposts]) == 1">
ads here
</if>
Also, make sure the template you're editing is in the same style you're using.
cellow
02-07-2013, 08:59 PM
doesnt work ... i dont understand why?!?
i delete datastore cache, deactivated, flushed xcache, rebuild bit_fields .... everything tried... i dont understand, why my this condition doesnt work in postbit_legacy template:
<!-- message -->
<if condition="($post[postcount] % $vboptions[maxposts]) == 1">
<div style="float:left; width:301px; height:251px; border:0px solid #336699;margin-left:2px;margin-right:15px;">
adtag comes here ...
</div>
</if>
<div id="post_message_$post[postid]">
$ad_location[ad_showthread_firstpost_start]
$post[message]
</div>
<!-- / message -->
Are you sure you're using postbit_legacy and not postbit (is the user information on the left or on top)? And if you have more than one style are you editing the same one that you're using?
cellow
02-07-2013, 09:11 PM
just 1 style and for sure postbit_legacy (userinfo is left) ....
something going wrong here ... i dont know what ...
If you take out the <if> completely do you see ads?
Edit: oh, well you said guests are still seeing them so I guess it won't make any difference. I really can't think what it could be. I guess it could be that there's an error somewhere in that template so that it's not saving the changed version (but normally it will tell you there's an error when you save it).
This may be a stupid question, but are you sure you're working on the right site (and not a test site or something)? I guess you'd know that since the other pages worked.
There is a post cache but I'm pretty sure it only caches the actual post text. If you want you could try truncating the postparsed table in the database. Edit: no, that can't be it - it certainly doesn't cache the rendered postbit template.
cellow
02-07-2013, 09:34 PM
no, even this it doesnt show ... i also tried to use directly editing the template without the template modification system ...
oh, right, i forgot you're using the template modification system. I don't know anything about that.
Simon Lloyd
02-07-2013, 09:54 PM
Tomorrow i'll modify my mod to set to show in set forums for each ad variable, it might be easier for you to use.
cellow
02-07-2013, 11:08 PM
after searching dozen of template modifications in the TMS , i found in postbit_legacy template, a stupid typo ... i didnt close </if> the condition in previous lines before my ad conditions begins...
now works everything like a charm :)
kevin, thank you very much... how can i donate you?
--------------- Added 1360282143 at 1360282143 ---------------
Tomorrow i'll modify my mod to set to show in set forums for each ad variable, it might be easier for you to use.
that would be nice (thank you!)
--------------- Added 1360283687 at 1360283687 ---------------
is there any way of conditions to define main-forumid (including all subforumids) without typing all subforumids?
thank you 4 ur support...
Simon Lloyd
02-08-2013, 06:05 AM
You can donate to Kevin here https://vborg.vbsupport.ru/showthread.php?t=294633&nojs=1#gtdonate or any "Support Developer" link in any of his mods. Do you really need me to work on mine now you have this working?
As for forumid selection you could have a multi select list in options settings to select them, Kevin, being a lateral thinker might have another way around it :)
Thanks, but there's no need for a donation. You can donate to Simon when he builds you the mod you need.
Simon Lloyd
02-08-2013, 05:11 PM
Should have this finished later today when i get home, it will be able to display any or all ads in any or all forums, and what's great is you can still add conditionals around the ads to show to specifi usergroups....etc
--------------- Added 1360424435 at 1360424435 ---------------
Ok, this is strictly beta and has had very minimal testing as i dont have much time, you need to have Template-Modifications Manager installed to use this right now but i will develop it further (time allowing) so if you want to test it pm me for the zip file.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.