Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2012, 01:34 AM
Mikhailtech Mikhailtech is offline
 
Join Date: Aug 2002
Location: USA
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to get a widget to only display on home page? (ad related)

I'm trying to get an ad/widget to only display on the home page of my site. The ad management system in VB won't let me do that and I can't figure out a way to get a widget to only display on the home page. I'm ok modifying a php file to custom include something in just the home page if that's necessary. Any thoughts?
Reply With Quote
  #2  
Old 03-05-2012, 01:12 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you talking about widgets on the CMS, or ads/forum blocks on the forum?
Reply With Quote
  #3  
Old 03-09-2012, 02:16 AM
Mikhailtech Mikhailtech is offline
 
Join Date: Aug 2002
Location: USA
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Widgets on the CMS. Really anything on just the front/home page of the CMS. If it requires modification of a php file to manually insert content that's ok, I just don't know which one.
Reply With Quote
  #4  
Old 03-11-2012, 03:19 PM
Mikhailtech Mikhailtech is offline
 
Join Date: Aug 2002
Location: USA
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
  #5  
Old 03-11-2012, 06:24 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Copy the template for the widget (shown in the Configure box) and then put a condition around the new widget template code to only show it on the first page. Make sure you edit the widget's template name (again, shown in the Configure box) to the new template name.
Reply With Quote
  #6  
Old 03-19-2012, 01:56 AM
Mikhailtech Mikhailtech is offline
 
Join Date: Aug 2002
Location: USA
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's the code for the condition? This is a "static HTML" type widget.
Reply With Quote
  #7  
Old 03-19-2012, 02:18 AM
dano9258 dano9258 is offline
 
Join Date: Feb 2012
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne answered this on another forum numerous times already...I wish i could find it right now but I can't. Just keep doing a search on Google or here and you will find it.
Reply With Quote
  #8  
Old 04-17-2012, 04:10 PM
Mikhailtech Mikhailtech is offline
 
Join Date: Aug 2002
Location: USA
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump ... couldn't find the answer to this. Lynne can you give an example on how to put a condition around this widget? I am not a coder so this is pretty confusing to me. TIA
Reply With Quote
  #9  
Old 04-17-2012, 04:24 PM
kkinsey kkinsey is offline
 
Join Date: Oct 2011
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I'm a little confused - CMS widgets only show up on the content.php page anyway --- which is "home" on most sites.

That out of the way, a PHP widget to do this could probably look something like this:
PHP Code:
if ($_SERVER['REQUEST_URI']=="/" || $_SERVER['REQUEST_URI']=="/index.php") {

   echo 
"<tags>my Html code here</tag>";
   echo 
"more HTML\n";
// end 'if' 
"/index.php" would be the actual page portion of the main site's URL, and it's placed there in case people come to it from a link other than "/". Be certain that if you use the double quote for your echo() statement, you only use single quotes for html tag properties, and HTML entities for any quotes in the text itself.

I hope I've not confused you in return
Reply With Quote
  #10  
Old 04-17-2012, 04:34 PM
Mikhailtech Mikhailtech is offline
 
Join Date: Aug 2002
Location: USA
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I sort of found it in this thread: https://vborg.vbsupport.ru/showthrea...home+page+only

So based on what was said here, I made a new template called: vbcms_widget_static_page_home

Here's the code for it:

Code:
<vb:if condition="$_GET[r] == "">

<div class="cms_widget">
	<div class="block">
		<div class="cms_widget_header">
		<h3><img src="{vb:stylevar imgdir_siteicons}/html.png" alt="" /> {vb:raw widget_title}</h3>
		</div>
		<div class="cms_widget_content widget_content">
		{vb:raw static_html}
		</div>
	</div>
</div>

</vb:if>
Then for my static HTML widget I put this as the template under the "configure" option like you said. However, when I go to save this template I get the following error:

Quote:
The following error occurred when attempting to evaluate this template:
%1$s
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
And the when I reload my home page I get this at the top:

Quote:
Parse error: syntax error, unexpected ')' in /home/xxxx/public_html/includes/class_core.php(4596) : eval()'d code on line 1
And the widget doesn't show up at all. So what am I doing wrong here?
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05236 seconds
  • Memory Usage 2,248KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete