11
novlang1984
Re: place div on homepage only

Just perfect. Bookmarked !

Thanks :)

12
bjuti
Re: place div on homepage only
  • 2011/3/26 11:24

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


Great.. this should be in the core package :)

Tnx Trabis!

13
deka87
Re: place div on homepage only
  • 2012/8/8 10:30

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


Let me revive this topic. The trabis solution seems to be perfect because <{if $xoops_dirname == 'system'}> would display the div on the search page as well. But the thing is his preload gives a blank page on the latest xoops installation. Any fixes?

14
Feichtl
Re: place div on homepage only
  • 2012/9/1 16:53

  • Feichtl

  • Not too shy to talk

  • Posts: 126

  • Since: 2004/11/8


@trabis: Works perfect! Should be part of the core!

@deka87: You have to include this part of the code in the exisiting file "core.php"

if (defined("XOOPS_STARTPAGE_REDIRECTED") || (isset($GLOBALS['xoopsOption']['template_main']) && $GLOBALS['xoopsOption']['template_main'] == "db:system_homepage.html")) {
            if (
is_object($GLOBALS['xoopsTpl'])) {
                
$GLOBALS['xoopsTpl']->assign('homepage' ,true);
            }
        }


into the function

function eventCoreHeaderAddmeta($args)


In my case i pasted it below line 60.

15
irmtfan
Re: place div on homepage only
  • 2012/9/2 9:29

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


IMO the better approach is to define a smarty for one unique xoops_startpage_redirected php variable in class/theme.php

in class/theme.php
$this->template->assign(array(
            
'xoops_theme' => $GLOBALS['xoopsConfig']['theme_set'] ,
            
'xoops_imageurl' => XOOPS_THEME_URL '/' $GLOBALS['xoopsConfig']['theme_set'] . '/',
            
'xoops_themecss' => xoops_getcss($GLOBALS['xoopsConfig']['theme_set']),
            
'xoops_requesturi' => htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES),
            
'xoops_sitename' => htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES),
            
'xoops_slogan' => htmlspecialchars($GLOBALS['xoopsConfig']['slogan'], ENT_QUOTES),
            
'xoops_dirname' => isset($GLOBALS['xoopsModule'])&& is_object($GLOBALS['xoopsModule']) ? $GLOBALS['xoopsModule']->getVar('dirname') : 'system',
            
'xoops_banner' => ($GLOBALS['xoopsConfig']['banners'] && $this->renderBanner) ? xoops_getbanner() : '&nbsp;',
            
// START irmtfan add startpage_redirected
            
'xoops_startpage_redirected' => defined("XOOPS_STARTPAGE_REDIRECTED"),
            
// END irmtfan add startpage_redirected
            
'xoops_pagetitle' => isset($GLOBALS['xoopsModule']) && is_object($GLOBALS['xoopsModule']) ? $GLOBALS['xoopsModule']->getVar('name') : htmlspecialchars($GLOBALS['xoopsConfig']['slogan'], ENT_QUOTES)));



then in your theme.html or any template you can use this syntax:

<{if $xoops_startpage_redirected || (!$xoops_startpage_redirected && $xoops_dirname == 'system') }>


The above smarty syntax maybe consider as a harder way in the first look but it is more comprehensive.
It said This is homepage IF
- a module other than system is set for startpage and the user is in index.php
OR
- no module is set for startpage and the user is in index.php

The above is good way for forward compatibility. (can work in the future xoops versions)

edit:
Quote:

<{if $xoops_dirname == 'system'}> would display the div on the search page as well.

If you want the specific page like index.php be the homepage again please use smarty like this:
<{if $xoops_startpage_redirected || ( !$xoops_startpage_redirected && $xoops_dirname == 'system' && ($xoops_requesturi == '/index.php' || $xoops_requesturi == '/') )}>


it means it is index.php or in the website domain.

Edit2:
I found it is easier to use $SCRIPT_NAME rather than $xoops_requesturi
so the above would be changed to:
<{if $xoops_startpage_redirected || ( !$xoops_startpage_redirected && $SCRIPT_NAME == '/index.php' )}>


With XOOPS you have too many options!!!

Edit3:
pay attention that $SCRIPT_NAME is case sensitive and should be write by uppercase alphabets.

16
deka87
Re: place div on homepage only
  • 2012/9/2 10:42

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


good solutions, guys! now using it. should be in core for sure.

17
Mamba
Re: place div on homepage only
  • 2012/9/2 10:58

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Quote:
good solutions, guys! now using it. should be in core for sure.

Please add it to Requests, and include a link to this thread, so the Core team can track it.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

18
irmtfan
Re: place div on homepage only
  • 2012/9/2 11:36

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


I investigate the request in this topic further and IMO we dont need a new smarty for a homepage anymore.
and i was wrong and we dont need that XOOPS_STARTPAGE_REDIRECTED smarty too because we have the definition now.

we already have everything and define a new smarty is unneeded and confusing.
because homepage is a confusing definition and everybody have its own definition for it.

1- if you mean homepage = www.yoursite.com then use this:
<{if $SCRIPT_NAME == 'index.php' }> 
This is your website www.yoursite.com => <{$xoops_url}><br/>
<{/if}>

I found that in my last post i was wrong and the above code is perfectly work when you have any module as start page.

2- if you mean homepage = your module start page use this
<{if $smarty.const.XOOPS_STARTPAGE_REDIRECTED==}>
XOOPS_STARTPAGE_REDIRECTED is true<br>
your start page module = <{$xoops_dirname}>
<{elseif 
$xoops_dirname == 'system'}>
your start page module system
<{/if}>


And you can make everything you want with the current smarties
eg: take index.php and search.php as homepages.

<{if $SCRIPT_NAME == '/index.php'  || $SCRIPT_NAME == '/search.php' }> 
This is your homepage<br/>
<{/if}>


So IMO no need for more confusing.
Just we need a very detail tutorial about XOOPS smarty variables.

Now our xoops users should search for many hours to find their needs.

19
Bleekk
Re: place div on homepage only
  • 2012/9/3 5:28

  • Bleekk

  • Theme Designer

  • Posts: 940

  • Since: 2002/12/14


Or you can use this smarty
<{$xoops_requesturi}>

- requested url (e.g. /modules/news/article.php?storyid=1)

20
irmtfan
Re: place div on homepage only
  • 2012/9/3 6:43

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


$xoops_requesturi will return the whole URL with all parameters so if for example we have xlanguage module install it will not work if user click on the english image because the URI will be:
index.php?lang=english

so using <{$xoops_requesturi}> will not work in all conditions.
but $SCRIPT_NAME will return the script_name so all the following URIs will have the same result $SCRIPT_NAME='/index.php'
www.yoursite.com/index.php?lang=english
www.yoursite.com/index.php?lang=persian
www.yoursite.com/index.php?lang=french
www.yoursite.com/index.php
www.yoursite.com/

....

but with $xoops_requesturi you have 5 different results and it is hard to manage them.
in my last post i forgot to add a slash before index.php
so please use if you mean homepage = www.yoursite.com:
<{if $SCRIPT_NAME == '/index.php' }> 
This is your website www.yoursite.com => <{$xoops_url}><br/>
<{/if}>


Also please pay attention that for subdomains you should add the subdomain because $SCRIPT_NAME and $xoops_requesturi will return whole url after your domain.
so add for a subdomain homepage like this:

<{if $SCRIPT_NAME == '/SUB_FOLDER/index.php' }> 
This is your website www.yoursite.com => <{$xoops_url}><br/>
<{/if}>



Login

Who's Online

170 user(s) are online (110 user(s) are browsing Support Forums)


Members: 0


Guests: 170


more...

Donat-O-Meter

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

Latest GitHub Commits