Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: global level up link :)  (Read 1379 times)

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
global level up link :)
« on: May 11, 2008, 08:54:58 pm »

 :D hey all
here is a function that will output a Dynamic Link to upper level from current location,
if in admin, pages, categories will output link to home,
for snews 16 subcat mod, if on subcategory will output link to parent category and so on,
if in article will give link back to category/subcategory.
works in snews 17rc aswell.  :P

Code: [Select]
<?php
# \\\\\\\\\\\\\\\\\\\\\\
# FUNCTION LEVELUP
# Use this to call the link where ever needed:
#  levelup();
# by: moshe gil lamberger 
#
function levelup(){
    
$sdir='/DIR NAME HERE/'// with slashes
$uril $_SERVER['REQUEST_URI'];
$rc explode('/',$uril);
$rcb=array_slice($rc2, -2true);
$binkr='';
foreach ($rcb as $key => $value){
if( $key>=){
$binkr.= $rcb[$key].'/';
} else {
$binkr.= $rcb[$key];
}
}
if(!empty($rcb)){
            
# for sNews 17 switch commented lines.
echo '<a href="'.db('website').$binkr.'" title="'.l('back').'">'.l('back').'</a>';
# echo '<a href="'._SITE.$binkr.'" title="'.l('back').'">'.l('back').'</a>';
} elseif ( $uril!=$sdir ) {
            
# for sNews 17 switch commented lines.
echo '<a href="'.db('website').'" title="'.l('home').'">'.l('home').'</a>';
# echo '<a href="'._SITE.'" title="'.l('home').'">'.l('home').'</a>';
}
}
# ////////////////////
?>


Use:
can be added to any html container or as is (function output link <a> ).

1) add or include the function at top.
2) in the first line enter the directory name where snews installed, with slashes.
Code: [Select]
<?php
$sdir
='/DIR NAME HERE/'// with slashes
?>


3) add the tag where needed:
Code: [Select]
<?php levelup(); ?>


 :D
awesome day


update: fixed error with dir name, and link title and name display.

« Last Edit: May 11, 2008, 09:22:09 pm by mosh »
Logged