vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   How to get a widget to only display on home page? (ad related) (https://vborg.vbsupport.ru/showthread.php?t=279542)

Mikhailtech 03-05-2012 01:34 AM

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?

kh99 03-05-2012 01:12 PM

Are you talking about widgets on the CMS, or ads/forum blocks on the forum?

Mikhailtech 03-09-2012 02:16 AM

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.

Mikhailtech 03-11-2012 03:19 PM

bump

Lynne 03-11-2012 06:24 PM

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.

Mikhailtech 03-19-2012 01:56 AM

What's the code for the condition? This is a "static HTML" type widget.

dano9258 03-19-2012 02:18 AM

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.

Mikhailtech 04-17-2012 04:10 PM

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

kkinsey 04-17-2012 04:24 PM

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 ;)

Mikhailtech 04-17-2012 04:34 PM

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?


All times are GMT. The time now is 02:39 PM.

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.01040 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete