Please login or register.

Login with username, password and session length
Pages: [1] 2

Author Topic: [MOD - mini] Byline with permalink  (Read 15492 times)

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
[MOD - mini] Byline with permalink
« on: June 04, 2007, 05:26:10 AM »

This mod was completely rewritten 7.16.07 -- credits to piXelatedEmpire and Zucye/bakercad
ииииииииииииииииииииииииииииииииииииииии*ииииииииииииииииииииииииииииииииииииииииииии
You want a byline for your articles? Separate from your normal "Read more" line? And you want it to include a permanent link to the article, regardless if the article is shortened or not?
Oki-doki. :cool:

Rule #1: Decide if you need this mod or not.
Rule #2: Back up your snews
-----------------------------------------------------------------------

* "Show infoline" must be selected for each article in order to display the byline. *

1. In Language variables, like within "#generic links", add
Quote
$l['permalink'] = 'Permalink';
$l['posted_in'] = 'Posted in'; //To use with category name
2. Change function INFO LINE TAGS, to this:
Quote
// INFO LINE TAGS (readmore, comments, date, permalink)
function tags($tag) {
   $tags = array(); $tags['infoline'] = '<p class="date">,readmore,comments,edit,</p>'."\n";
   $tags['comments'] = '<div class="comment">,<p class="byline"><strong>,name, said, '.l('on').' ,date,</strong>,edit,</p>,<p>,comment,</p>,</div>';
   $tags['byline'] = '<p class="byline">,permalink, | ,'.l('posted_in').',category_name,</p>'."\n";
   return $tags[$tag];

}
* The character | (pipe) is just a divider, you can choose your own. *

3. In function center(), around line 530 (depending on your number of mods), add the following (a straight clone of the "infoline" variable in the same block). I have mine directly after $keywords.
Quote
$byline = $r['displayinfo'] == 'YES' ? true : false;
4. A few lines below, find this line
Quote
$category = $r['category'] == 0 ? $home : retrieve('seftitle', 'categories', 'id', $r['category']);
Directly below it, add this:
Quote
$cat_name = $category == $home ? l('home') : retrieve('name', 'categories', 'seftitle', $category);
Then go down another couple of lines and find this:
Quote
if ($r['displaytitle'] == 'YES') { echo '<h2>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h2>'; }
And change it to this:
Quote
if ($r['displaytitle'] == 'YES') { echo '<h2>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h2>';
               if ($byline == true) {
                  $tag = explode(',', tags('byline'));
                  foreach ($tag as $tag ) {
                     switch ($tag) {
                        case ($tag == 'permalink'): echo $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.l('permalink').'</a> '; break;
                        case ($tag == 'category_name'): echo $link.$category.'/" title="'.$category.'">'.$cat_name.'</a> '; break;
                        default: echo $tag;
                     }
                  }
               }
            }
And you're done.

A living example of the mini-mod can be seen here.
Note: as I am a PHP analphabet, there may be oddities in the mod that could be scraped away for a cleaner result. Or a totally different way of doing it. I've tested the mod both locally and live on two different 1.6 installations. No problems I have seen (once it was completed that is...).

Enjoy ;)
« Last Edit: December 19, 2007, 02:37:16 AM by Fred K (agentsmith) »
Logged

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #1 on: June 04, 2007, 06:56:10 AM »

Oh freddie boy pucker up love because I've got one hell of a big wet kiss coming your way *mmmmmmwah!!!!* :P

Just the MOD I was working on!  Terrific, stupendious, marvellous!

*does the dance of joy*

So I get a bit excited bout sNews, so waht :lol:
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 947
    • cssanarchy.com
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #2 on: June 04, 2007, 07:03:55 AM »

Hej piXelatedEmpire what happend with your web site...coming soon or what  :D
Logged
Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #3 on: June 04, 2007, 06:20:46 PM »

Quote from: piXiE
mmmmmmwah!
glad you finds it useful, pix. :)

* can someone bring me a towel? / sniffs air / what's that cologne ... Foster's? no, a BIG towel, can't you see I'm drenched? *
:lol: :o :lol:

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #4 on: June 05, 2007, 01:38:30 AM »

Foster's rofl... no no we only export that stuff.. it's terrible!!  It's all about Carlton draught my friend ;)

sasha... my first site is nearly ready for release, just fine tuning the CSS to fit sNews and tweaking the gallery section :)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 947
    • cssanarchy.com
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #5 on: June 05, 2007, 05:52:55 AM »

nice :)
Logged
Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #6 on: June 06, 2007, 11:11:14 AM »

Nice work centered! Though
Quote from: centered
For those rare 1.4 users
maybe it would be better to post the solution in the 1.4 Mods forum ... to avoid confusion? It's easy to include a link back to this post to maintain lineage (if necessary).
Just a thought.

centered

  • Guest
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #7 on: June 06, 2007, 01:05:49 PM »

Logged

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #8 on: June 07, 2007, 02:17:53 AM »

I'd suggest removing or editing your post here as well centered ;)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #9 on: June 12, 2007, 12:10:16 PM »

A question relating to this MOD... if one has implemented bakercad's Clickable Article Title MOD, then a permalink is not required right, as they are basically the same thing?

Edit: heh, I answered my own question
Quote
Sometimes, the article title itself is a hyperlink, in which case it is typically the Permalink for that article.
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[MOD - mini] Byline with \
« Reply #10 on: June 12, 2007, 01:05:25 PM »

Just a note for anyone else whom might have an issue with this MOD:
This line:
Quote
$tags['byline'] = '<p class="byline">,permalink, | ,Posted in ,category, '.l('on').' ,date,</p>';
MUST BE pasted AFTER:
Quote
$tags = array(); $tags['infoline'] = '<p class="date">,readmore,comments,date,edit,</p>';
Only took me a few minutes to figure this one out ;)


Annnnnd one more thing :D
A slight modification to the language variables (remove hardcoded English words ;))
1. In Language variables, like within "#generic links", add
Quote
$l['permalink'] = 'Permalink';
$l['posted_in'] = 'Posted in ';
2. In function INFO LINE TAGS, find:
Quote
$tags = array(); $tags['infoline'] = '<p class="date">,readmore,comments,date,edit,</p>';
add below it add the following:
Quote
$tags['byline'] = '<p class="byline">,permalink, | , '.l('posted_in').' ,category, '.l('on').' ,date,</p>';
* The character | (vertical pipe) is a divider. *

Top MOD smitty :D
« Last Edit: November 09, 2007, 02:12:47 PM by philmoz »
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #11 on: June 13, 2007, 01:52:10 PM »

piXiE -- 1) Yeah, I guess they are essentially the same except that in my version you get a specific permalink, rather than having the title clickable at all times. Like you said in that FAQ of yours ...
Quote
At the end of the article, there is a link that is labeled "link" or "permalink".
Which one to use is up to your preferences.

2) Yes, the "byline" array must be after
Quote
$tags = array();
I didn't really think about that since it seemed so obvious ... :lol:
Will update the first post to reflect this. Thanks!

3) Good addition. And just so that there isn't any confusion about the vertical pipe: you can use any divider you like. I like pipes. ;)

Glad you likes it, mate. :cool:

Zucye

  • Sr. Member
  • ****
  • Karma: 5
  • Posts: 354
    • Simplemente una Mujer
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #12 on: June 29, 2007, 07:55:48 AM »

I found this mod quite nice, but since I am using the Clickable Article Titles mod, I donњt have a need for the permalink.  Now, I would really like to show the category name in the info line, but when using the following line, I only get to display the SEF name.  How can I show the category name?
Quote
case ($tag == 'categoryname'): echo $link.$category.'/" title="'.$category.'">"'.$category.'" '; break;
(I am probably not explaining this correctly, just take a look at my info line after "Publicado en", and you will see what I mean.)
Logged
We can always learn from our failures, not so much from obvious success - C. Robinson (W. Disney). :)

Zucye

  • Sr. Member
  • ****
  • Karma: 5
  • Posts: 354
    • Simplemente una Mujer
[MOD - mini] Byline with \
« Reply #13 on: July 13, 2007, 07:29:32 PM »

It works now (thanks to Bod).  It goes like this:
Quote
After:
case ($tag == 'date'): echo $a_date_format; break;

I added:
case ($tag == 'categoryname'): echo $link.$category.'/" title="'.$cat_name.'">"'.$cat_name.'"</a> '; break;

Also Added "categoryname" to the info line - mine looks somehow like this:
$tags = array(); $tags['infoline'] = '<p class="date">,Published in ,categoryname, '.l('on').' ,date, ............

Last part as per BOD:
In the center function find this line:
$category = $r['category'] == 0 ? $home : retrieve('seftitle', 'categories', 'id', $r['category']);

After it, ADD this line:
$cat_name = $category == $home ? l('home') : retrieve('name', 'categories', 'seftitle', $category);
« Last Edit: November 09, 2007, 02:13:19 PM by philmoz »
Logged
We can always learn from our failures, not so much from obvious success - C. Robinson (W. Disney). :)

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
[MOD - mini] Byline with "permalink" (sNews 1.6)
« Reply #14 on: July 14, 2007, 01:27:12 PM »

Thanks, Z -- very nice. I guess I'll have to rewrite the mod post now that there are such an amount of changes to the original... ;)

@those who use the original byline mod, all you need to do is a) change "category" in the infoline tags function to something like "category_name"; b) do this
Quote from: Zucye
In the center function find this line:
$category = $r['category'] == 0 ? $home : retrieve('seftitle', 'categories', 'id', $r['category']);

After it, ADD this line:
$cat_name = $category == $home ? l('home') : retrieve('name', 'categories', 'seftitle', $category);
and c) find this line
Quote
case ($tag == 'permalink'): ... break;
and ALTER the next line so that it looks something like this:
Quote
case ($tag == 'category_name'): echo $link.$category.'/" title="'.$category.'">'.$cat_name.' '; break;
Original post will be rewritten accordingly in a little while.
Pages: [1] 2