Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Design and Graphics Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2007, 09:29 AM
RobParker RobParker is offline
 
Join Date: Nov 2006
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to set style depending on location on site?

Hi all,

Hopefully this is possible and simple as it's really important that we manage to get this done.

We have a VB site running vbadvanced as the homepage/news section and then linking to our forums.

We have the header and footer templates modified to put the right hand column down the side of the entire site on every page and use this column for our adverts. The code for the ads themselves are linked through a plugin we've set.

The code looks like this:

Code:
<!-- Right Column Code  -->
</td>
<td width="120" valign="top" align="left">$advertcode</td>
</tr>
</table>
</td></tr>
</table>
<!-- End Left Column Code -->
The plugin is then:

Code:
ob_start();
   include('urls/to/site/forums/adverts.php');
   $advertcode= ob_get_contents();
ob_end_clean();
And the adverts.php file contains the html/javascript for our adverts.

The problem we have now is that we need to differentiate between our forums pages and our other pages and display different advertising code depending on the two.

What we basically need to do and what I hope is possible is that we can do the following:

Code:
<!-- Right Column Code  -->
</td>
<td width="120" valign="top" align="left">

IF location = forums ($advertcode)
ELSE ($newadvertcode)

</td>
</tr>
</table>
</td></tr>
</table>
<!-- End Left Column Code -->
And add in some kind of if statement to set the code to a different plugin to display different ads depending on whether you're on the forums or not.

Is this possible at all? It's quite urgent as we've just been informed that we need to make this change ASAP.

Cheers for any help.

Rob
Reply With Quote
  #2  
Old 04-12-2007, 02:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

At the top of your forumsdisplay.php file, it has something like this:
PHP Code:
define('THIS_SCRIPT''forumdisplay'); 
So I think you can use that variable, THIS_SCRIPT, to do your if statement.
PHP Code:
<if condition="THIS_SCRIPT == 'forumdisplay'"
$advertcode
<else />
$newadvertcode
</if> 
Reply With Quote
  #3  
Old 04-12-2007, 03:03 PM
RobParker RobParker is offline
 
Join Date: Nov 2006
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Superb.

That doesn't quite do what I need but is certainly along the right lines.

forumdisplay, showthread, newreply etc would all need to be included in the condition but something like

THIS_SCRIPT == '(forumdisplay' OR 'showthread' OR etc etc)

should work.

I think I'm right in saying it's also possible to do it by forumid so I could display just certain ads in our "news" forums but not in the others, right?

Ideally what I'd have is:

Front page/vbadvanced modules

Forum pages relating to forums 1 and 2.

Forum pages relating to forums id 3-10 (for example)

I think with a nested IF statement then I can both select the scripts as well as the forum ids.

If anyone is able to post what code they should I should be using it'd be great but I think I can figure it out now.

Thanks again.
Reply With Quote
  #4  
Old 04-12-2007, 07:09 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think this is kinda what you want, but I don't know what the THIS_SCRIPT display is for vbadvanced (I don't have it on my site):

PHP Code:
<if condition="THIS_SCRIPT == 'forumdisplay' OR THIS_SCRIPT == 'vbadvanced'"
$advertcode
</if>
<if 
condition="in_array($foruminfo[forumid], array(1,2))"/>
$newadvertcode
</if>
<if 
condition="in_array($foruminfo[forumid], array(3,4,5,6,7,8,9,10))"/>
$anotheradvertcode
</if> 
That's assuming there is no overlap in forumdisplay/vbadvanced and any of the forumids, or else you would nest the foruminfo conditional with the other depending on which one takes precedence.

(This isn't tested and I'm no expert, so some tweaking may be necessary. )
Reply With Quote
  #5  
Old 04-12-2007, 07:45 PM
RobParker RobParker is offline
 
Join Date: Nov 2006
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne.

That's not quite what I need as there has to be an else statement in there(I don't think I explained myself as well as I could have done) but at least I understand what I need to do now.

The THIS_SCRIPT for VBA is adv_index for the homepage by the way. Once I've tested it out I'll post what I ended up using.
Reply With Quote
  #6  
Old 04-14-2007, 02:56 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, you probably want the else before the forum part, something like:
PHP Code:
<if condition="THIS_SCRIPT == 'forumdisplay' OR THIS_SCRIPT == 'adv_index'"
$advertcode
<else />
<if 
condition="in_array($foruminfo[forumid], array(1,2))"/>
$newadvertcode
</if>
<if 
condition="in_array($foruminfo[forumid], array(3,4,5,6,7,8,9,10))"/>
$anotheradvertcode
</if>
</if> 
You know better than I what the exact conditional would be for your forums, so just tweak it until it reads right for you.
Reply With Quote
  #7  
Old 04-18-2007, 01:25 PM
RobParker RobParker is offline
 
Join Date: Nov 2006
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quick question on syntax.

Why do you close off you're if statements after the first one?

For example the closing / here:

PHP Code:
<if condition="in_array($foruminfo[forumid], array(1,2))"/> 
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 06:50 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04122 seconds
  • Memory Usage 2,230KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete