Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: tiny [MOD] - separating title and body generation  (Read 4723 times)

rob101

  • Newbie
  • *
  • Karma: 9
  • Posts: 22
tiny [MOD] - separating title and body generation
« on: November 01, 2007, 08:21:53 PM »

In many sites, you may want to place the title and body of your 'center' content in different places.
Or, you may want to style the differently with separate <div>s.

So, here's my little three line mod to allow you to do it. Just alter the following lines of snews.php :
Code: [Select]
Line 438: function center($want="all", $suppress_error=FALSE) {
Line 444: if ($want=='all' || $want=='body'){switch(true) {
Line 452: }}
Line 453: if ($_SESSION[db('website').'Logged_In'] == token()  && ($want=='all' || $want=='body')) {
Lines 475 - 479:
case 'archive': if ($want=='all' || $want=='body'){archive();}; break;
case 'sitemap': if ($want=='all' || $want=='body'){sitemap();}; break;
case 'contact': if ($want=='all' || $want=='body'){contact();}; break;
case 'login': if ($want=='all' || $want=='body'){login();}; break;
case '404': if ($want=='all' || $want=='body'){error404();}; break;
Line 482: $title_not_found = $suppress_error == TRUE ? '' : '<h2>'.l('not_found').'</h2>';
Line 523: if ($r['displaytitle'] == 'YES' && ($want == 'title' || $want == 'all')) {echo '<h2>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h2>';}
Line 524: if ($want=='body' || $want=='all') {file_include(str_replace('[break]', '', $text), $shorten);}//REO

This will now mean that you can do things like:

Code: [Select]
<div class="article_title"><?php center('title'TRUE); ?></div>
<div class="article_text"><?php center('body'); ?></div>

Naturally,
Code: [Select]
<?php center(); ?> still works as normal.

I hope that's helpful.  ;D

(Update: extra code added.)
« Last Edit: November 02, 2007, 01:47:29 PM by rob101 »
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 955
Re: tiny [MOD] - separating title and body generation
« Reply #1 on: November 01, 2007, 08:50:11 PM »

Congrats - handy one, with minimal fuss and preserving old ways ;)
Logged

rob101

  • Newbie
  • *
  • Karma: 9
  • Posts: 22
Re: tiny [MOD] - separating title and body generation
« Reply #2 on: November 01, 2007, 08:59:04 PM »

Cheers. Don't use it yet though - it's buggy! (I've realised that three lines does not a mod make.)
I'll post updates shortly...
Logged

rob101

  • Newbie
  • *
  • Karma: 9
  • Posts: 22
Re: tiny [MOD] - separating title and body generation
« Reply #3 on: November 01, 2007, 09:17:11 PM »

OK, I added more lines to modify - the original mods ended up doubling up any administrative displays on a page.

It's now eleven lines rather than three, which isn't ideal, so maybe I'll look at another way of doing this whilst staying in the 'sNews' style.

BTW: Whoot, I got karma - cheers. How can you tell where / when it was given to you?
Logged

philmoz

  • High flyer
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 2001
    • fiddle 'n fly
Re: tiny [MOD] - separating title and body generation
« Reply #4 on: November 01, 2007, 09:40:07 PM »

I assume you are working on a raw snews.php.
Also, you might want to amend
Quote
So, here's my little three line mod

but, 3 or 11 lines, it is still a handy mod.

RE:Karma... you can't unless user mentions it in a post, somethning like :-

+Karma for this. (and yes, I did)
« Last Edit: November 01, 2007, 09:46:46 PM by philmoz »
Logged
Of all the things I have lost, it is my mind that I miss the most.

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6290
  • Semantically Challenged
    • snews.ca
Re: tiny [MOD] - separating title and body generation
« Reply #5 on: November 01, 2007, 09:44:53 PM »

BTW: Whoot, I got karma - cheers. How can you tell where / when it was given to you?
It happens when someone else (any registered member) decides to click on your UP karma link.  ;)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 391
    • My snews with AEF Forum site
Re: tiny [MOD] - separating title and body generation
« Reply #6 on: November 01, 2007, 09:47:50 PM »

like now... :D

this will certainly affect the Templating of the Articles. Nice.
There is also a mod around here someplace to "break apart" the date components which should work very nicely with your Mod to allow Designers a great deal more flexibility in the presentation.
Excellent work. And thank you.
Logged
Yes! I have no siggy.

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
Re: tiny [MOD] - separating title and body generation
« Reply #7 on: November 01, 2007, 11:36:00 PM »

This is a terrific little addition wel done sir!
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

rob101

  • Newbie
  • *
  • Karma: 9
  • Posts: 22
Re: tiny [MOD] - separating title and body generation
« Reply #8 on: November 02, 2007, 01:49:46 PM »

Cheers for the +ve feedback.

I've added another line, which avoids errors appearing on pages without a title, such as the admin page.
You can 'opt in'  to this by adding TRUE as the second variable in the call. eg:

Code: [Select]
<?php center('title'TRUE); ?>
Still backward compatible.

I assume you are working on a raw snews.php.
If only!  ;) But the line numbers should refer to an untampered version.
« Last Edit: November 02, 2007, 01:52:30 PM by rob101 »
Logged

sidisinsane

  • Guest
Re: tiny [MOD] - separating title and body generation
« Reply #9 on: November 23, 2007, 01:24:08 PM »

Great mod!
One thing though. If my settings allow the display of the info line (read more/comments/date), it is shown beneath both title and body instead of just the latter.

Since I'm thinking about disabling comments anyway, this isn't that big of an issue to me that I am willing to spend much time on. Still, maybe someone knows of an easy workaround.
Logged