PDA

View Full Version : widget only on one page.


emath
11-17-2010, 08:25 AM
i have created a static html widget,
and i want it to be shown only on the main page.

i mean, when someone navigates to an article for e.g , this widget will dissappear.

to see what i mean, you can go to www.emath.co.il and click the menu on the right side.. the articles are changed, but the top widget stays.

any ideas?

thanks

Lynne
11-17-2010, 01:32 PM
Your example is of a widget that stays on all article pages, but it sounded like you wanted a widget that disappears on all article pages. Can you clarify this?

If you want a widget to disappear on some pages that are in the same section, you will have to create a custom template for it that has a condition around it to only show on page x (node == x). Insert that custom template name in the Configure screen for the widget.

emath
11-17-2010, 02:38 PM
can u give me the full condition for that ?

Lynne
11-17-2010, 05:58 PM
You'd have to look in the template to see what the variable name is. I can't just guess. It would be something like:
<vb:if condition="$variable[node] == x">stuff</vb:if>

You may be able to use r.
<vb:if condition="$_GET[r] == x">stuff</vb:if>

emath
11-17-2010, 06:06 PM
sorry , i dont understand...

this is the only code ive in the template :

{vb:raw static_html}

and it called : vbcms_widget_static_page_no_border

i want that this widget will appear only on the first page . if navigating to other category or artice, the widget will be gone.

from where i need to get the variable name ? u said "to look in the template to see what the variable name is"

ive paste the template code :S

and what is X ?

thank alot lynne.

Lynne
11-17-2010, 09:03 PM
The template gets evaled somewhere and variables get used in it. If all that is in it is that one line, then I honestly don't know what variable you can use. Usually there is code right before a template is rendered in the code and all the variables get defined that you may use in that template. You'd have to find where it is evaled to see what the name of the variable is.

As for x, x is the nodeid.

emath
11-17-2010, 09:24 PM
i think you misunderstood me.

i need a if condition that will do this :

if main cms page
render the widget[widget code]
else
dont render the widget
if end

is that what u guide me to ?

if so, where can i search where the template gets evaled..?

Lynne
11-17-2010, 10:05 PM
And that is what you would be doing if you put and if condition around it based on the nodeid.

I don't know where you are evaling that template. It's not a default template. Since you said it's an html widget, I'd guess in the widget/static.php file. I'm thinking you are going to have to just go with $_GET[r] (r is in the browser url of the page)

emath
11-18-2010, 06:49 AM
ive tried like these ways (none of them worked) :

<vb:if condition="$_GET['http://www.emath.co.il/'] == 'index-1'">
{vb:raw static_html}
</vb:if>

<vb:if condition="$_GET[r] == 'index-1' ">
{vb:raw static_html}
</vb:if>

emath
11-20-2010, 01:01 PM
any help please?

where do i get the nodeid ?

Lynne
11-20-2010, 02:21 PM
The node id is in the URL. If your condition is for the very front page, sometimes r is NULL, so you need to say "if it equals index-1 or it doesn't exist".

emath
11-20-2010, 05:12 PM
thanks, sorry for bothering so much.

this worked for me :

<vb:if condition="$_GET[r]=='' ">
{vb:raw static_html}

</vb:if>