Author Topic: [MOD] Cat name in clickstream->to the page# where image i  (Read 62738 times)

0 Members and 1 Guest are viewing this topic.

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
[MOD] Cat name in clickstream->to the page# where image i
« on: June 08, 2003, 07:41:58 AM »
This little addon will make category link in the clickstream (on details.php page) pointing on the page where the image is.
Lets try explain one more time with an example ;)
Lets say u click on an image from "random image", then, u can see in the clickstream path of that image ( Home / cat name / subcat name / image name )
then, u click on category name in the clickstream ( subcat name ). It will open categories.php page on first page, but to find where was that image u might need go next page, then maybe next and next and next... I found this little bit anoying, so this mod will help with that "problem" - it will open categories.php page on page where the image is ( categories.php?cat_id=xx&page=xx )


Step 1.
Open /details.php
Find:
Code: [Select]
unset($image_id_cache);Add before:
Code: [Select]
$cur_page = ceil((array_search($image_id, $image_id_cache) + 1) / $perpage);
Step 1.2.
Find:
Code: [Select]
$clickstream .= get_category_path($cat_id, 1).$config['category_separator'];Replace with:
Code: [Select]
$clickstream .= get_category_path($cat_id, 1, $cur_page).$config['category_separator'];
Step 2.
Open /includes/functions.php
Find:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0) {Replace with:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0, $page = 0) {
Step 2.2a original
I leave this "version" of Step 2.2a so u have a chose ;)
Personaly I'd suggest use Step 2.2b by effemmess

Find:
Code: [Select]
       if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
         if (!empty($regs[1]) && $regs[1] != 1) {
           $cat_url .= "&".URL_PAGE."=".$regs[1];
         }
       }
Replace with:
Code: [Select]
      if ($page > 1) {
         $cat_url .= "&".URL_PAGE."=".$page;
       }else{
       if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
         if (!empty($regs[1]) && $regs[1] != 1) {
           $cat_url .= "&".URL_PAGE."=".$regs[1];
         }
       }
     }

Step 2.2b by effemmess
Find:
Code: [Select]
 return $path;Add before:
Code: [Select]
 if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url."&amp;".URL_PAGE."=".$page)."\" class=\"clickstream\">page ".$page."</a>";
  }

Demo:
http://gallery.vano.org/5686
(click at category name in top-left corner)
« Last Edit: June 21, 2006, 08:22:00 AM by V@no »
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)

drhtm

  • Guest
[MOD] Cat name in clickstream->to the page# where image i
« Reply #1 on: June 08, 2003, 11:13:03 AM »
works like a charm.  Great idea!

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[MOD] Cat name in clickstream->to the page# where image i
« Reply #2 on: June 08, 2003, 08:11:57 PM »
Excellent.  It's annoyed me too and I meant to look into it but didn't have the time.

Thanks!

Offline Sheep707

  • Full Member
  • ***
  • Posts: 165
    • View Profile
    • http://www.leeger.net
useful
« Reply #3 on: June 08, 2003, 08:53:28 PM »
:D Useful Mod!!!

Thx V@no
Wer einen Rechtschreibefeher findet, kann ihn behalten!

Offline rp

  • Newbie
  • *
  • Posts: 36
    • View Profile
Extra Link to Subcat on Detail Page
« Reply #4 on: June 08, 2003, 11:49:35 PM »
Thank you V@no this is very usefull Mod!

Is it possible to have an extra link on the detail Page which brings you directly to the page where the thumbnail image is. This would be some kind of an extract from the clickstream on the detail Page.

Example
Clickstream:  Home / cat name / subcat name / image name
Extra Link to: subcat name

For Your Demo this would be:
http://come.no-ip.com/categories.php?cat_id=6&page=64

Any Idea, how this could be done?
Thank you, Romeo

Offline effemmess

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
[MOD] Cat name in clickstream->to the page# where image i
« Reply #5 on: June 11, 2003, 03:45:35 AM »
Hi all,
I have little addon to v@noīs addon:

If you would to have the clickstream in the form as
Home / cat name / subcat name / page2 / image name
then you must do the following in addition to (after!) v@noīs steps:
Step 3.1.
Open /includes/functions.php
Find:
Code: [Select]
$cat_url .= "&amp;".URL_PAGE."=".$page;
Replace with:
Code: [Select]
$pagereg= "&amp;".URL_PAGE."=".$page;

Step 3.2
Find:
Code: [Select]
 return $path;
Add before:
Code: [Select]
 if ($page>1){
    $path=$path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url.$pagereg)."\" class=\"clickstream\">"."Seite ".$page."</a>";
  }


greetz
effemmess

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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #6 on: June 11, 2003, 03:57:02 AM »
exelent! great idea! :D :idea:
added to my site too ;)

P.S. with your modifications, u dont even need do Step 2.2
u can simply add your modifications like this:
Code: [Select]
 if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url."&amp;".URL_PAGE."=".$page)."\" class=\"clickstream\">page ".$page."</a>";
  }
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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #7 on: June 11, 2003, 04:19:13 AM »
Alright, now I'm confused.  I already implemented this mod when it was posted.  

What do I have to change to include the changes from effemmess and V@no  :?:  I can't get this to work.

<cough>  Maybe edit the original post?  :wink:

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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #8 on: June 11, 2003, 04:46:32 AM »
ok, I've added it to the original post.
I left old Step 2.2., so ppl who already installed it, could restore the changes.
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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #9 on: June 11, 2003, 05:29:56 AM »
If anyone would like to see this clickstream in categories.php
Home / cat name / subcat name / Page2

Open categories.php

Find:
Code: [Select]
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].get_category_path($cat_id)."</span>";

Replace with:
Code: [Select]
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].get_category_path($cat_id, ($page > 1), $page)."</span>";

Offline effemmess

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
[MOD] Cat name in clickstream->to the page# where image i
« Reply #10 on: June 11, 2003, 03:05:06 PM »
Hi,
I have a new addon to my addon of v@noīs addon...,  :D
and a question to discuss.
First the addon:
If you want it in your language you must do following:

In Step 2.2. by effemmess
do not add:
Code: [Select]
 if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url."&amp;".URL_PAGE."=".$page)."\" class=\"clickstream\">page ".$page."</a>";
  }

but
Code: [Select]
 if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url."&amp;".URL_PAGE."=".$page)."\" class=\"clickstream\">".$lang['page']." ".$page."</a>";
  }

Step 2.3. by effemmess
Find:
Code: [Select]
 global $site_sess, $config, $cat_cache, $url;
Replace:
Code: [Select]
 global $site_sess, $config, $cat_cache, $url,$lang;
Step 3. by effemmess
Open /lang/.../main.php
Add wherever you want after
Code: [Select]
<? and before
Code: [Select]
?>
this
Code: [Select]
$lang['page'] = "Seite"; // or whatever you want (e.g. straniza  :-) )

Thatīs all.
--------------------------
And now the question:
If I do not do
Code: [Select]
        if ($page > 1) {
           $extension= "&amp;".URL_PAGE."=".$page;
         }else{
           if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
             if (!empty($regs[1]) && $regs[1] != 1) {
               $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
             }
           }
         }

and in consequence
Code: [Select]
 if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url.$extension."=".$page)."\" class=\"clickstream\">".$lang['page']." ".$page."</a>";
  }

the value of $regs[1] == $page and in consequence the subcat hasnīt the link to page1. In v@noīs demolink itīs okay, but why??? :?:
Here is my complete not functioning function get_category_path
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0, $page = 0) { //nicht i.O.
  global $site_sess, $config, $cat_cache, $url, $lang;
  $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)) {
      if ($detail_path) {
        $cat_url = ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id;
        if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
          if (!empty($regs[1]) && $regs[1] != 1) {
            $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
          }
        }
        $path = "<a href=\"".$site_sess->url($cat_url)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>";
      }
      else  {
        $path = $cat_cache[$cat_id]['cat_name'];
      }
    }
    else {
      $path = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>".$config['category_separator'].$path;
    }
    $cat_id = $parent_id;
  } // end while
  if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url."&amp;".URL_PAGE."=".$page)."\" class=\"clickstream\">".$lang['page']." ".$page."</a>";
  }
  return $path;
}

And here is my complete at my site functioning function get_category_path
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0, $page = 0) { // i.O.
  global $site_sess, $config, $cat_cache, $url, $lang;
  $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)) {
      if ($detail_path) {
        $cat_url = ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id;
        if ($page > 1) {
          $cat_url_ext = "&amp;".URL_PAGE."=".$page;
        }
        else{
          if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
            if (!empty($regs[1]) && $regs[1] != 1) {
              $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
            }
          }
        }
        $path = "<a href=\"".$site_sess->url($cat_url)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>";
      }
      else  {
        $path = $cat_cache[$cat_id]['cat_name'];
      }
    }
    else {
      $path = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>".$config['category_separator'].$path;
    }
    $cat_id = $parent_id;
  } // end while
  if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url.$cat_url_ext)."\" class=\"clickstream\">".$lang['page']." ".$page."</a>";
  }
  return $path;
}

Has anybody (v@no) an idea? :?:  :?
cu

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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #11 on: June 11, 2003, 08:28:17 PM »
Quote from: effemmess
I have a new addon to my addon of v@noīs addon...,  :D
LMAO :lol: good one ;)
actualy I cheated...:D ;)
I have modifyed the function, so, it wont show link for / page 2 when u are browsing categories, and only show as a link from details.php
I think would be better if I just show u my function:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0, $page = 0, $page_details = 0) {
  global $site_sess, $config, $cat_cache, $url, $lang;
  $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)) {
      if ($detail_path && ($page > 1 || $page_details)) {
        $cat_url = ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id;
       if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
         if (!empty($regs[1]) && $regs[1] != 1) {
           $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
         }
       }
        $path = "<a href=\"".$site_sess->url($cat_url)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>";
      }
      else  {
        $path = $cat_cache[$cat_id]['cat_name'];
      }
    }
    else {
      $path = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>".$config['category_separator'].$path;
    }
    $cat_id = $parent_id;
  } // end while
  if ($page > 1){
    $pagereg = "&amp;".URL_PAGE."=".$page;
    $page = ($page_details) ? "<a href=\"".$site_sess->url($cat_url.$pagereg)."\" class=\"clickstream\">".$lang['lang_userlist_page'].$page."</a>" : $lang['lang'].$page;
    $path = $path.$config['category_separator'].$page;
  }
  return $path;
}

then, in details.php I changed call function to this:
Code: [Select]
 $clickstream .= get_category_path($cat_id, 1, $cur_page, 1).$config['category_separator'];
and in categories.php to this:
Code: [Select]
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].get_category_path($cat_id, 1, $page)."</span>";

P.S. not sure why this happend, but sometimes when I enter in details.php, both / cat_name / and / page 2 / have link with &page=2
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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #12 on: June 11, 2003, 08:46:22 PM »
I know why and I already fixed it yesterday.  :wink:

I'll post what I did in a few minutes.

Offline Xwall

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.xwall.tk
[MOD] Cat name in clickstream->to the page# where image i
« Reply #13 on: June 11, 2003, 08:58:14 PM »
Well somebody can put all the correct steps in only one post   :?
iīm feeling  :evil:   :!:  :idea:  :lol:

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
[MOD] Cat name in clickstream->to the page# where image i
« Reply #14 on: June 11, 2003, 09:04:51 PM »
Quote from: Xwall
iīm feeling  :evil:   :!:  :idea:  :lol:

ah, no, its not good when Xwall feels :evil:.... 8O
;) j/k
lets way for Chris. but for now, u can do:
1) steps from 1 to 2.1 and chose step 2.2. from either of two in the original post
2) do "version" from my post above. (it's compleate mod there just search in details.php and categories.php for $clickstream find very simular to the one u need change it ;))
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)