1
stpamx
Is it possible to check for a pagetype within my theme
  • 2003/12/4 19:57

  • stpamx

  • Just popping in

  • Posts: 19

  • Since: 2003/9/14


Insert this around the top of your theme file:
<{php}>
$module $GLOBALS['xoopsModule'];
if ( isset(
$module) ) {
    
$module $module->getVar('dirname');
} else {
    
$module 'system';
}
$GLOBALS['xoopsTpl']->assign('modname'$module);
<{/
php}>


All the lines below this block will then be able to acces the new variable "modname" (that's why I told you to put this around the top).
Example:
<link rel="stylesheet" href="<{$xoops_imageurl}><{$modname}>.css" />

or

<
body class="<{$modname}>">
...


Skalpa.>

2
Herko
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/4 20:13

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


Skalpa.. next time please press 'reply' in stead of 'edit'

Herko

3
stpamx
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/4 20:24

  • stpamx

  • Just popping in

  • Posts: 19

  • Since: 2003/9/14


Thanks scalpa.

I will try this.

I will try to repost the question in case someone else can benefit from this.

4
stpamx
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/4 20:44

  • stpamx

  • Just popping in

  • Posts: 19

  • Since: 2003/9/14


ORIGINAL QUESTION

Is it possible to check for a pagetype within my theme.

The need is to be able to format a page according to its actual needs.

It could be very usefull if we use different modules.
For example I am using Enterprise-x and TinyContent.

I want within my theme to check what pagetype I am and accordingly to format the page.
for example

If pagetype = "enterprise-x"
.......

elseif
pagetype = "news"
.......

etc

your help will be appreciated

Thanks in advance
stelios

5
stpamx
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/4 21:36

  • stpamx

  • Just popping in

  • Posts: 19

  • Since: 2003/9/14


It works fine with style sheets and modules.
Thanks a lot scalpa.

However it is possible to do same with pagetype, as it gives more flexibility?

For example with modules, I cannot have different style sheets for users page, as it returns system.

Thanks again
stelios

6
skalpa
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/5 6:45

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Quote:
Skalpa.. next time please press 'reply' instead of 'edit'



Sorry m8s, I just made this answer before going to sleep. Looks like I really needed it
(and in fact I made 2 posts yesterday night, I just hope I didn' do the same with the 2nd one )

For the "pagetype" by itself, there is a variable that modules should set but all of them don't do it. However I think this should work (at least for the users page). Add these lines at the end of the php block I gave above.
if ( isset( $GLOBALS['xoopsOption']['pagetype'] ) ) {
    
$GLOBALS['xoopsTpl']->assign('pagetype'$GLOBALS['xoopsOption']['pagetype'] );
}


Sorry again

Skalpa.>

7
stpamx
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/5 8:23

  • stpamx

  • Just popping in

  • Posts: 19

  • Since: 2003/9/14


Thanks again.

I will try it
stelios

8
stpamx
Re: Is it possible to check for a pagetype within my theme
  • 2003/12/5 18:44

  • stpamx

  • Just popping in

  • Posts: 19

  • Since: 2003/9/14


NO Problem I found it - Thank you


I have tried desperetely
to check the page type and/or module name but it always goes to other. Although when I attach it to a statement(like .css) it gives me the correct code. In this case "user".

can you tell me what is wrong in the following php statement in html
<{if $pagetype == "user"}>
user
<{else}>
other
<{/if}>

I have included

<{php}>
$module = $GLOBALS['xoopsModule'];
if ( isset($module) ) {
$module = $module->getVar('dirname');
} else {
$module = 'system';
}
$GLOBALS['xoopsTpl']->assign('modname', $module);

if ( isset( $GLOBALS['xoopsOption']['pagetype'] ) ) {
$GLOBALS['xoopsTpl']->assign('pagetype',
$GLOBALS['xoopsOption']['pagetype'] );
}
if (isset( $GLOBALS['xoopsConfig']['language'] ) ) {
$GLOBALS['xoopsTpl']->assign('language',
$GLOBALS['xoopsConfig']['language'] );
}
<{/php}>

on the top in my html theme

Login

Who's Online

409 user(s) are online (289 user(s) are browsing Support Forums)


Members: 0


Guests: 409


more...

Donat-O-Meter

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

Latest GitHub Commits