Author Topic: Dynamic change to page title  (Read 18931 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Dynamic change to page title
« on: September 30, 2002, 03:58:06 AM »
Hmmm... just curious.

Is there any way to do something like this in the header.html template?
Code: [Select]
<title>{site_name}: {clickstream}</title>

Obviously this doesn't work as "clickstream" contains HTML tags.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Dynamic change to page title
« Reply #1 on: September 30, 2002, 07:37:50 AM »
WIthout modification, no. But you can register a additional template variable for each page. Just duplicate $clickstream and remove all html tags.

For example for categories.php:

Add to categories.php:
Code: [Select]
$clickstream2 = $config['site_name'].$config['category_separator'].get_category_path_nohtml($cat_id);

Than replace

Code: [Select]
"clickstream" => $clickstream
with
Code: [Select]
"clickstream" => $clickstream,
"clickstream2" => $clickstream2


You see the new function get_category_path_nohtml(). Just add the following code to "includes/functions.php:
Code: [Select]
function get_category_path_nohtml($cat_id = 0) {
  global $config, $cat_cache;
  $parent_id = 1;
  while ($parent_id) {
    if (!isset($cat_cache[$cat_id]['cat_parent_id'])) {
      return false;
    }
    $parent_id = $cat_cache[$cat_id]['cat_parent_id'];

    if (empty($path)) {
      $path = $cat_cache[$cat_id]['cat_name'];
    }
    else {
      $path = $cat_cache[$cat_id]['cat_name'].$config['category_separator'].$path;
    }
    $cat_id = $parent_id;
  } // end while
  return $path;
}


Hope this will help.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Thanks
« Reply #2 on: October 01, 2002, 01:36:46 AM »
As always, your mod works perfectly.  I also added the {clickstream2} code to all php files that referenced {clickstream}.  

Now I get a descriptive page title on all my 4images pages.  This is so much more informative for the logs produced by my page logging and visitor tracking script.

Wow.  Thanks again.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Dynamic change to page title
« Reply #3 on: October 20, 2002, 07:27:38 AM »
was searching for the answer here, but couldnt find.
what is CLICKSTREAM? what does it do?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Clickstream = bread crumbs
« Reply #4 on: October 20, 2002, 06:41:48 PM »
Clickstream generates what is sometimes commonly called "bread crumbs".  This shows you the route by which you navigated to where you are at the moment.  (Follow the trail of bread crumbs...?)

For an example, go here:  http://demo.4homepages.de/details.php?image_id=22

And you will see the clickstream is
Code: [Select]
Home / Objekte / AfriCola

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Dynamic change to page title
« Reply #5 on: April 28, 2003, 04:43:30 PM »
Thanks too.
But can it be taken one step further, so that in details.php it shows the site name : category: image name ?

Also, I can't seem to get this to function on the index.php page.
The title now comes out with just the url instead of atleast the site title.

Thanks again,

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Dynamic change to page title
« Reply #6 on: April 28, 2003, 05:17:59 PM »
Here's what I did.

It required updating nearly all the top-level 4images .php files.  But I'm now able to see the clickstream in the page titles of my visitor tracking and statistics script output.  As an example, I'm only going to show details.php:
Code: [Select]

//-----------------------------------------------------
//---Clickstream---------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
$clickstream_nohtml = $config['category_separator'].$lang['home'].$config['category_separator']; // <--- page title clickstream

if ($mode == "lightbox" && $in_mode) {
  $page_url = "";
  if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
    if (!empty($regs[1]) && $regs[1] != 1) {
      $page_url = "?".URL_PAGE."=".$regs[1];
    }
  }
  $clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$lang['lightbox']."</a>".$config
['category_separator'];
  $clickstream_nohtml = $config['category_separator'].$lang['lightbox'].$config['category_separator']; // <--- page title clickstream
}
elseif ($mode == "search" && $in_mode) {
  $page_url = "";
  if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
    if (!empty($regs[1]) && $regs[1] != 1) {
      $page_url = "&amp;".URL_PAGE."=".$regs[1];
    }
  }
  $clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."search.php?show_result=1".$page_url)."\" class=\"clickstream\">".$lang['search']."</a
>".$config['category_separator'];
  $clickstream_nohtml = $config['category_separator'].$lang['search'].$config['category_separator']; // <--- page title clickstream
}
else {
  $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  $clickstream_nohtml = $config['category_separator'].get_category_path_nohtml($cat_id).$config['category_separator']; // <--- page title clickstream
}
$clickstream .= $image_name."</span>";
$clickstream_nohtml .= $image_name; // <--- page title clickstream

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  "clickstream_nohtml" => $clickstream_nohtml, // <--- page title clickstream
  "lang_category" => $lang['category'],
  "lang_added_by" => $lang['added_by'],
  "lang_description" => $lang['description'],
  "lang_keywords" => $lang['keywords'],
  "lang_date" => $lang['date'],
  "lang_hits" => $lang['hits'],
  "lang_downloads" => $lang['downloads'],
  "lang_rating" => $lang['rating'],
  "lang_votes" => $lang['votes'],
  "lang_author" => $lang['author'],
  "lang_comment" => $lang['comment'],
  "lang_prev_image" => $lang['prev_image'],
  "lang_next_image" => $lang['next_image'],
  "lang_file_size" => $lang['file_size']
));

This allows me to use:
Code: [Select]
<title>{site_name} {clickstream_nohtml}</title>
in my header.html template.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Dynamic change to page title
« Reply #7 on: April 28, 2003, 05:30:09 PM »
Perfect

Thanks much,

Offline jaimecb

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Dynamic change to page title
« Reply #8 on: April 19, 2005, 10:27:01 PM »
i have an error.. my title is :

Quote
www.MisImagenes.net // Album de Fotos Peņa - <span class="clickstream"><a href="./index.php" class="clickstream">Principal</a>&nbsp;/&nbsp;<a href="./categories.php?cat_id=24" class="clickstream">AŅO 2005</a>&nbsp;/&nbsp;<a href="./categories.php?cat_id=28" class="clickstream">9 de Abril - Chango</a>&nbsp;/&nbsp;Juanje Fash</span>

:S you can see here

Code: [Select]
http://www.misimagenes.net/details.php?image_id=1010   for details
Code: [Select]
http://www.misimagenes.net/categories.php?cat_id=24      for categories

how can i resolve that ?? :S

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
Re: Dynamic change to page title
« Reply #9 on: April 19, 2005, 10:47:02 PM »
versuch mal diesen code
http://www.4homepages.de/forum/index.php?topic=6613.0
try this!

 8) vincent
Beati pauperi spiritus

4images 1.7 // My Installed Mods


Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: Dynamic change to page title
« Reply #10 on: April 20, 2005, 02:56:46 AM »
Thanks Vincent.

The code posted in this thread is out-of-date.  Please use the published mod instead:

[MOD] Dynamic Page Title for v1.7 & v1.7.1

LOCKED