Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: Anchor links  (Read 1587 times)

ad_267

  • Jr. Member
  • **
  • Karma: 7
  • Posts: 57
Anchor links
« on: October 23, 2007, 10:48:35 pm »

I wanted to have links to anchors within my page (eg. a link back to the top of the page) but these didn't work. I found this topic: http://snewscms.com/forum/index.php?topic=1822.0 for snews1.4 that didn't work with 1.6 so I fiddled round a bit with that code and came up with this:

Under #generic links: $l['top'] = 'Back to top';

// ADD LINK TO ANCHOR
function anchor($anchor_id) {
   $categorySEF = get_id('category');
    if ($categorySEF != '') {
    $categorySEF .= '/';
    }
   $articleSEF = get_id('article');
    if ($articleSEF != '') {
    $articleSEF .= '/';
    }
    $anchor_link = '#'.$anchor_id;
   $link = '<a href="'.db('website').$categorySEF.$articleSEF.$anchor_link.'" title="'.l($anchor_id).'">'.'';
   echo $link;
}

Is this the right way to do this? It seems to work alright, but I know hardly anything about php and how sNews works.
Logged