Name: Add news title and/or category to <title>
Author: Ifa
Updated: 18.11.2008
Cutenews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Adds the news title and/or category between your <title> tags
Instructions: This hack will add the news title and/or category that is currently viewed to the page title (<title></title>).
Add this code to your file that includes cutenews. Put this between the <head></head> tags. Change the $path = 'cutenews/data'; to match your cutenews folder. And change the <title>default title</title> to what you want the title to be when it's not the news title.

if (is_array($category)) $category = ' - '.implode(' - ', $category);


This line is for multiple categories. By default it seperates the categories with a -, ie "title - category1 - category2 - category3".
You can freely change both - to suit your needs, just keep the ' '. The same goes with the line below, only this is for a single category.

else $cat = ' - '.$title_values[1];

$title_values = title_values($_GET['id'], TRUE); // Change TRUE to FALSE if you dont use a category


Like it says, if you don't want category in your title, change TRUE to FALSE. This only saves the script some extra work.

<?PHP
function title_values($id, $use_category)
    {
                $path = './cutenews/data';//CHANGE PATH TO THE CUTENEWS DATA DIRECTORY HERE
        if ($use_category)
        {
            $cat_lines = file($path.'/category.db.php');
            foreach ($cat_lines as $cat_line)
                {
                    $cat_array = explode('|', $cat_line);
                    $my_cats[$cat_array[0]] = $cat_array[1];
                }
        }

        $news_lines = file($path.'/news.txt');
        foreach ($news_lines as $news_line)
            {
                $news_array = explode("|", $news_line);
                if ($news_array[0] == $id)
                    {
                        $title = strip_tags($news_array[2]);

                        if ($use_category and !empty($news_array[6]))
                            {
                                if (strstr($news_array[6], ','))
                                    {
                                        $cat_array = explode(',', $news_array[6]);
                                        foreach ($cat_array as $category)
                                            $category_arr[] = $my_cats[$category];
                                    }
                                else $category_arr = $my_cats[$news_array[6]];
                            }
                    }
            }
        return array ($title, $category_arr);
    }

if (isset($_GET['id']))
    {
        $title_values = title_values($_GET['id'], true);//change true to false if the category doesn't need to be in the titlebar.
        $title = $title_values[0];
        if (is_array($title_values[1])) $cat = ' - '.implode(' - ', $title_values[1]);
        else $cat = ' - '.$title_values[1];

        echo '<title>'.$title.''.$cat.'</title>';
    }

else echo '<title>Default Title</title>';
?>

CuteFTP language packs! https://cutephp.com/forum/style_emoticons/default/biggrin.gif

https://cutephp.com/forum/style_emoticons/default/huh.gif

53

(2 replies, posted in Hacks & Tricks / FAQ)

So changing CHMOD will not make an error message dissapear

To make things clear, in most cases it doesn't work, but in
Warning: fopen(X): failed to open stream: Permission denied in /www/site/folder on line #
The error will go away with proper chmod https://cutephp.com/forum/style_emoticons/default/smile.gif

World Peace!

Oh and all bugs gone (major ones atleast)

smile

rofl you guys  big_smile
You can do that just by editing options.mdu. It's in there very begining of the file  tongue
All this talk about making a hack when it's in cutenews already  big_smile

I would like the next cutenews to have one feature... A magical button reads what I want from my mind and then does it... That would be so cool...  :specool:

big_smile

Posts found: 51 to 58 of 58

Pages Previous 1 2 3

CutePHP Forums → Posts by Ifa



The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.