Pages: [1]
Author Topic: different "welcome text" for each categories  (Read 460 times)
Customers
Jr. Member
*

Karma: 0
Posts: 26


on: Jun 08, 10, 03:56 PM

Hello,

somebody knows how to make a different "welcome text" for each categories ?

regards
Phil
« Last Edit: Jun 08, 10, 04:53 PM by mangabase » Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #1 on: Jun 09, 10, 05:36 AM

1. create an empty welcome_text.php
2. insert the following code in it:
Code:
<?php
$welcomeText 
'Your default text here';
$frontPageText 'Text for the front page';  // leave the string empty ('') to use the default one.
$gamePageText 'Text for game pages';  // leave the string empty ('') to use the default one.
$categoryText = array(
  
1  =>  'Text for the category with ID = 1',
  
4  =>  'Text for another category'
// and so on. 
// category IDs can be found on the cat. management page inside admin cp
);
  
$sScript substr(strrchr($_SERVER['PHP_SELF'], "/"), 1);

if( 
$sScript == 'cat.php' )
{
  if( !empty(
$categoryText[$nCategory]) )
     
$welcomeText $categoryText[$nCategory];
}
elseif( 
$sScript == "index.php" )
{
  if( !empty(
$frontPageText) )
    
$welcomeText $frontPageText;
}
elseif( 
$sScript == "game.php" )
{
  if( !empty(
$gamePageText) )
    
$welcomeText $gamePageText;
}

$tpl->assign"WELCOMETEXT"$welcomeText );
?>

3. upload the file to /content/blocks/ folder
4. in your admin cp edit settings for the "Welcome" block - switch its type to "PHP Script"
That's it.

Warning: the method is untested, so please post your results/questions here, I'll try to help.
Logged
Customers
Jr. Member
*

Karma: 0
Posts: 26


Reply #2 on: Jun 09, 10, 07:53 AM

Great !

Many thanks i'll try it and i give you a feedback ;-)

Logged
Customers
Jr. Member
*

Karma: 0
Posts: 26


Reply #3 on: Jun 18, 10, 03:36 PM

Hello i've try it an error message appear :

Warning: include(content/blocks/welcome_text.php) [function.include]: failed to open stream: No such file or directory in /home/jeux.manga-base.com/www/index.php on line 62

Warning: include() [function.include]: Failed opening 'content/blocks/welcome_text.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/jeux.manga-base.com/www/index.php on line 62
Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #4 on: Jun 20, 10, 08:41 AM

have you done the points 1 and 3?
Logged
Customers
Jr. Member
*

Karma: 0
Posts: 26


Reply #5 on: Jun 30, 10, 12:47 AM

Oups !!

i have forgot the "e" of th welcome file.... THANKS !!!

an other question how to have the correct accents in the php file (my language is french) ?
Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #6 on: Jun 30, 10, 05:28 AM

I guess you should save it in utf8 format (for example PSPad do have menu item "format" for this purpose)
Logged
Customers
Jr. Member
*

Karma: 0
Posts: 26


Reply #7 on: Aug 25, 10, 04:48 AM

Yep it's ok ;-)

many thanks
Logged
Pages: [1]
 
Jump to: