Hello

September 07, 2010, 04:55:29 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
What sNews Is: - sNews is a simple, basic, customizable CMS tool suitable for developers with beginner-to-advanced PHP skills. It is also useful to have a good working knowledge of how to work with, set up and manage MySQL databases. sNews is not - geared towards the end-user who knows little or nothing about building and developing PHP-MySQL based websites.
News: Try sNews 1.7 DEMO
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [MOD] Another Breadcrumb Fixer-Upper  (Read 381 times)
Fred K (agentsmith)
sNews Dude
ULTIMATE member
*****

Karma: 102
Posts: 2335


da- dadadaaaa


« on: July 06, 2010, 02:58:20 AM »

Mod: Changing function breadcrumbs so it doesn't print "Home" (linked or not) on the "Home" page.

Reason: It's been bugging me that there are all these (somewhat unnecessary) links to Home ... on the Home page. Some should be there. Some you can remove. Like the one in breadcrumbs. (This is a personal pet peeve, I'm not sure everyone will find the mod useful, but what the hey.)

Demo? Not live yet. As we say, it's "coming soon"...

**********^***********

0. Backup. You know you want to.

1. In index.php, make sure the breadcrumbs function call isn't wrapped in any HTML container, but instead is only
Quote
<?php breadcrumbs(); ?>

2. In snews.php, find the function breadcrumbs() and change it to the following:

Quote from: mod code
//BREADCRUMBS
function breadcrumbs() {
   global $categorySEF, $subcatSEF, $_POS, $_TITLE, $_NAME, $_XNAME;
   $link = '<a href="'._SITE.'';
   if (_ADMIN) {
      echo $link.'administration/" title="'.l('administration').'">'.l('administration').'</a> '.l('divider').' ';
   }
   if(empty($categorySEF)) {echo '';} //NEW LINE
   elseif (!empty($categorySEF)) {
   echo '<div id="crumbs">'.$link.'" title="Link to home page">'.l('home').'</a>'; //CHANGED
   if (!empty($categorySEF) && check_category($categorySEF) == false) {
      echo (!empty($subcatSEF) ? ' '.l('divider').' '.$link.$categorySEF.'/" title="'.(!empty($_XNAME) ? $_XNAME : $_NAME).'">
         '.(!empty($_XNAME) ? $_XNAME : $_NAME).'</a>' :
         (!empty($_NAME) ? ' '.l('divider').' '.$_NAME:''));
      if (!empty($subcatSEF) && $_XNAME) {
         echo ($_POS==1 ? ' '.l('divider').' '.$link.$categorySEF.'/'.$subcatSEF.'/">'.$_NAME.'</a>' : ' '.l('divider').' '.$_NAME);
      }
      echo (!empty($_TITLE)? ' '.l('divider').' '.$_TITLE : '');
   }
   if (check_category($categorySEF) == true && $categorySEF != 'administration' && $categorySEF) {
      echo ' '.l('divider').' '.l($categorySEF);}
   echo '</div>';} //NEW LINE
}

3. There is no step 3...
Cool

Note: On every page but "Home", the "Home link is of course preserved, the mod only changes the output on "Home".
Note 2: If anyone has suggestions for bettering, simplifying or economizing the code, I'm all eyes. (Me and PHP, not the best of friends.)

/* Edit: code cleaned up (there were some redundant bits left from my own build which shouldn't have been included). */
« Last Edit: July 06, 2010, 03:54:52 PM by Fred K (agentsmith) » Logged

Sven
ULTIMATE member
******

Karma: 76
Posts: 1857


Chasing MY bugs!


WWW
« Reply #1 on: July 06, 2010, 12:23:55 PM »

Good shot Fred!
Note 2: If anyone has suggestions for bettering, simplifying or economizing the code, I'm all eyes. (Me and PHP, not the best of friends.)
Nope, sorry: yours is shorter than mine.  Wink (I'm talking of your code of course)
« Last Edit: July 06, 2010, 12:25:35 PM by Sven » Logged

Fred K (agentsmith)
sNews Dude
ULTIMATE member
*****

Karma: 102
Posts: 2335


da- dadadaaaa


« Reply #2 on: July 06, 2010, 03:55:55 PM »

Merci, Philippe.
Logged

Sven
ULTIMATE member
******

Karma: 76
Posts: 1857


Chasing MY bugs!


WWW
« Reply #3 on: July 15, 2010, 10:28:15 AM »

Note: On every page but "Home", the "Home link is of course preserved, the mod only changes the output on "Home".
Dites-donc Monsieur Fred,
juste une petite question  Grin
"Home" when in the pagination process, is no more "Home" so when you're on "p_2" "Home" is still printed, right?
Is that the way you wanted it?
Logged

Fred K (agentsmith)
sNews Dude
ULTIMATE member
*****

Karma: 102
Posts: 2335


da- dadadaaaa


« Reply #4 on: July 15, 2010, 03:59:44 PM »

Philippe!!!
ba'non... je m'ennui du pagination... Cheesy
Honestly I didn't test it with pagination in place so it's a good petite question. I think the behaviour is reasonable and logical. I guess the only problem is that if you click a "p_1" link, the url says /domain/p_1/ but it's treated as "home" which might possibly be viewed as slightly illogical or ... illogical. I don't see it as a problem though. (Plus I have no idea et this time how one would remove Home from pagination on root level... Cool

Guess I have to test it with root pagination now just to see what it does. (I did the mod for a site that utilizes a "special" front page, so it will never have root pagination and I didn't stop to think about that, but it is a good question.)

Oh la-la, il fait chaud. Wink
Logged

Sven
ULTIMATE member
******

Karma: 76
Posts: 1857


Chasing MY bugs!


WWW
« Reply #5 on: July 16, 2010, 01:02:16 PM »

Mister Fredryk!
Oh la la! After the big heat usually come the storms. Take care of you. Cool
(...) I have no idea et this time how one would remove Home from pagination on root level... Cool
Jason? Are you're around? I think we need your light there. Wink


Logged

Fred K (agentsmith)
sNews Dude
ULTIMATE member
*****

Karma: 102
Posts: 2335


da- dadadaaaa


« Reply #6 on: July 22, 2010, 01:11:54 AM »

Here's a shorter version (although, @Philippe, it still doesn't remove Home from root secondary pages - p_2, p_3, p_x):

1. Revert to the original sNews breadcrumb code in snews.php.
2. In index.php, directly before your breadcrumb code (html + snews call), do this:

Code:
<?php if(!empty($categorySEF) { ?>

And then finish it by adding the following directly after your whole breadcrumbs part:

Code:
<?php ?>

So, the whole thing could look like this:
Code:
<?php if(!empty($categorySEF)) {?>
<div id="crumbs">
<?php breadcrumbs(); ?>
</div><?php ?>

That's all. That has got to be the shortest mod I've ever written...
Logged

Sven
ULTIMATE member
******

Karma: 76
Posts: 1857


Chasing MY bugs!


WWW
« Reply #7 on: July 22, 2010, 11:49:58 AM »

Finally Fred,
I moved it last night off the index and placed in the Core only for pages see :
Création de sites Web : la mise en page.

So I get rid of this home link when on paginated pages since there's no more breadcrumb there. Grin
Logged

Fred K (agentsmith)
sNews Dude
ULTIMATE member
*****

Karma: 102
Posts: 2335


da- dadadaaaa


« Reply #8 on: July 22, 2010, 03:20:10 PM »

Looks good. I don't normally critique other people's sites unless they ask for it, but there are a couple of spots you might want to look at.

The pagination: My French is crap, but if I go to blog/ there is a link saying "previous pages" and when I click it, it goes to page 2. If, on page 2, i click the link "next page" I get back to the blog front page. So Previous and Next appear to have been switched around.

The source: there are no opening and closing <html> tags, which I believe is non-validating if nothing else.

The header: it may be a matter of taste, but it would look better if it was moved up a couple of pixels, in Safari 5 at least there is a gap between the browser chrome and the header top.

Other than that it looks nice. Cheers.
« Last Edit: July 22, 2010, 03:34:49 PM by Fred K (agentsmith) » Logged

Sven
ULTIMATE member
******

Karma: 76
Posts: 1857


Chasing MY bugs!


WWW
« Reply #9 on: July 22, 2010, 04:42:00 PM »

Oh oh... inversion corrected for the pagination!
Thanks a lot Fred.

"no opening and closing <html> tags"? There are not needed at all. As well as body. As well a closing p tags (depending on what is following: sometimes it cause issues). And it validates.

The header? You mean the nav bar? I dont see any differences between Chrome, FF, Opera and Safari on my machine. Huh
Moving up a couple of pixels? I wanted it to stick at this place for the page scrolling under it.

Thanks for your kind remarks. Cool
Logged

Pages: [1]
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!