Welcome to Geeklog, Anonymous Monday, May 20 2024 @ 12:15 pm EDT

Geeklog Forums

links that contain '#'


Status: offline

xucaen

Forum User
Junior
Registered: 01/08/06
Posts: 24
artistic
I ran into a peculiar thing today with geeklog stories. Geeklog has a feature that extracts all links out of a story and lists them at the bottom under a heading "What's related". I really like the feature. However, today I posted a story that contains a table of contents using internal links. The syntax for these links is
Text Formatted Code

<a href='#label'>some text</a>

 


So, I had about a dozen of these showing up in the "What's related" list. UGH!

So, I located the code that builds the list and added a line to skip links that contain a '#'.
Obviously, this is a short term fix. There is a problem with what to do with legitimate links that contain a '#'. I probably won't want to skip those.

For now, here's my fix. I changed file lib-story.php, function STORY_extractLinks().

Text Formatted Code

        //Jim Barrett
        //2006-02-01
        //I need to exclude href that contains '#' within my url
        //so, testing if link contains a '#'
        //if no, save it, else skip it.
        //TODO: what if I link to someone else's site and it contains a '#'?
        //I will need to a way to test if my site or not.
        if(stristr($matches[1][$i], '#') === FALSE) {
            $rel[] = '<a href="' . $matches[1][$i] . '">'
                   . str_replace ("/(\015\012)|(\015)|(\012)/", '', $matches[2][$i])
                   . '</a>';
        }


 


Jim
 Quote

Status: offline

rasher

Forum User
Newbie
Registered: 03/21/04
Posts: 12
Quote by xucaen:There is a problem with what to do with legitimate links that contain a '#'. I probably won't want to skip those.


try this if statement instead.
Text Formatted Code
if ( ! ereg ("^#", $matches[1][$i]) )
 


This just says, if $matches does NOT start with a # then continue.
It would allow anything that didn't have a # as the first character through.
 Quote

Status: offline

xucaen

Forum User
Junior
Registered: 01/08/06
Posts: 24
try this if statement instead.
Text Formatted Code
if ( ! ereg ("^#", $matches[1][$i]) )


 


This just says, if $matches does NOT start with a # then continue.
It would allow anything that didn't have a # as the first character through.


Hi, Thanks! Very Happy

Jim
 Quote

All times are EDT. The time is now 12:15 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content