1
maxima
Is there a TOP PAGE smarty identifier?
  • 2007/2/3 15:18

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


I just spent an hour searching and now out time. I want to add a smarty (if) switch to my theme to execute an action when the home page is displayed. I tried
<{if xoops_page == "top"}>Do this<{/if}>

but that did nothing.

I have been successfully using
<{if $xoops_pagetitle == "home"}>Do this<{/if}>

but now I want to put a slogan in the title and want to change it periodically but don't want to have to modify the theme file each time.

So does anyone know what can be used to identify the home page?

2
wodnick
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/3 17:09

  • wodnick

  • Just popping in

  • Posts: 32

  • Since: 2006/12/30


Hi there!

Try to examine $xoops_dirname - "is globally available in themes and holds the directory name of the currently selected module".

Something like this:
<{if $xoops_dirname==''}>Do this<{/if}>


regards,
wodnick
========
Pozycjonowanie

3
maxima
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/3 22:58

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


Thanks for the suggestion but that didn't work.

4
patagon
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/4 0:41

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


I had the same problem and I (kind of) fixed it by doing a test with javascript to check what the url was and write something if it was the home (i.e. if the url was www.mydomain.com/index.php display this). I cant find the code though, but if you know javascript or programming maybe this helps (I dont...I managed to do it once but it took a lot of time and there's got to be a better solution)

5
skenow
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/4 1:08

  • skenow

  • Home away from home

  • Posts: 993

  • Since: 2004/11/17


If you define a module for your top page, the link for 'Home' is www.yoursite.com/modules/<module>/, not www.yoursite.com or www.yoursite.com/index.php

You will want to compare your current url to $xoops_url or the new xoAppUrl

6
pod
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/4 10:41

  • pod

  • Quite a regular

  • Posts: 301

  • Since: 2003/4/19


If you are not using a module for your top page, the easiest way to approach this is:

[color=009900]<{if !empty($xoops_contents)}>[/color]
Display this if viewing a module
[color=009900]<{else}>[/color]
Display this if viewing front page 
[color=009900]<{/if}>[/color]



Hope this helps!
www.myxoops.com - MyXoops Is Your XOOPS!

7
maxima
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/6 2:01

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


I am thinking that the core system recognizes the home page by a smarty tag just like the module directories. Can a core member please give a suggestion???

8
blueteen
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/6 7:07

  • blueteen

  • Quite a regular

  • Posts: 379

  • Since: 2004/7/16


hello,
here's what i'm using :
on my website, 'news' module is used for the top page.
I want to display a block on top page only, not on others pages of this module.

top page =http://www.site.fr/modules/news/

others pages :http://www.site.fr/modules/news/index.php?storytopic=X
or
http://www.site.fr/modules/news/article.php?storyid=X

-

create a file : myfile.php
with this :
<?php
if ($_SERVER['REQUEST_URI'] == "/modules/news/")
{
$this->assign('top_page''1');
}
?>


in your theme.html, add this ligne (under <body> tag)
<{include_php file="$xoops_rootpath/themes/my_theme/myfile.php"}>


then, I can use smarty like this, to display a block only on top page :
<{if $top_page == "1"}>
your code here
<{/if}>


hope this can help you !

9
maxima
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/8 2:08

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


I thought there was a simple smarty to recognize the home page. As it seems no one know of such I will just go back to what I was using {page_title) since it's simpler. Thanks for the suggestions.

10
blueteen
Re: Is there a TOP PAGE smarty identifier?
  • 2007/2/8 6:26

  • blueteen

  • Quite a regular

  • Posts: 379

  • Since: 2004/7/16


my solution doesn't work ?

Login

Who's Online

98 user(s) are online (69 user(s) are browsing Support Forums)


Members: 0


Guests: 98


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits