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: home articles's title to be Different with other.  (Read 402 times)

adminphp

  • Full Member
  • ***
  • Karma: 4
  • Posts: 150
  • you must be a great snewser .
home articles's title to be Different with other.
« on: September 29, 2012, 06:26:12 AM »

Hi guys! Its me again. hope you are fine.
last few days I have started making some fixes on my website. particularly in stylesheet in order to be compatible with all navigators... I wanted to have a Different article's title style. for instance i want titles which is in homepage to be Different (center it - color -) with the titles inside (when we get into a post). thanks
Logged
“Fifty years of programming language research, and we end up with C++?”

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: home articles's title to be Different with other.
« Reply #1 on: September 29, 2012, 08:20:43 PM »

OK, I believe the title for articles uses <h2>title</h2>.

In your CSS file, you can add new style declarations to your CSS file that you would only use for colors. Here are three examples for the colors red, green and purple (you can name them for any color and use the corresponding # for the color):
Code: [Select]
.red { color: #ff0000; }
.green { color: green; }
.purple { color: purple; }
... of course you can add other styling to these as well, such as a bottom border:
Code: [Select]
.red { color: #ff0000; border-bottom: 1px solid #eee; }
.green { color: green; border-bottom: 2px solid #eee; }
.purple { color: purple; border-bottom: 3px dotted #eee; }

Then you search in your snews.php file (or any function file being used) for <h2> to find where the titles are being generated, and add your color to the opening <h2> tag like this... using the examples shown above:
Code: [Select]
<h2 class="red">
<h2 class="green">
<h2 class="purple">
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

adminphp

  • Full Member
  • ***
  • Karma: 4
  • Posts: 150
  • you must be a great snewser .
Re: home articles's title to be Different with other.
« Reply #2 on: September 29, 2012, 09:50:18 PM »

First thanks for the reply. unfortunatley I think you didn't understand my request.

you provide a clear way to add a declaration to my css file to color the title for articles (outside/inside). But what i wanted exactly is to add a different style for title of articles.

to explain this well:  titles usually uses <h2>title</h2> in homepage (means articles for a short text and inside for a full text).
but i want titles of full article (text) to be shown in a diffirent way with short onefor instance center it and have another color.

so can we have this:
<h2>title</h2>
shorten text
infoline
<h2>title</h2>
shorten text
infoline

and when we click on a title. inside have to be like this:

<div id="title_css">title</div>
full text
-----
infoline
comment form.
could this lines be the responsible of this sort of process:
Code: [Select]
if ($r['displaytitle'] == 'YES') {echo '<h1>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h1>';}
« Last Edit: September 30, 2012, 12:19:14 AM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: home articles's title to be Different with other.
« Reply #3 on: September 30, 2012, 06:48:59 AM »

when we click on a title. inside have to be like this:

<div id="title_css">title</div>
full text
-----
infoline
comment form.


could this lines be the responsible of this sort of process:
Code: [Select]
if ($r['displaytitle'] == 'YES') {echo '<h1>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h1>';}
You can do it this way.  You will want: <h1 class="title_css">

Or, you can add an id/class to the body, then style from there: http://snewscms.com/forum/index.php/topic,5807.0.html
Logged

adminphp

  • Full Member
  • ***
  • Karma: 4
  • Posts: 150
  • you must be a great snewser .
Re: home articles's title to be Different with other.
« Reply #4 on: September 30, 2012, 07:26:33 AM »

oh my god, I do not know if it's me who couldn't explain well what i want. or you didn't understand the request exactly.
ok let see if i could do more;
Well, basically we have two kinds of text in snews 1.6 and all version i think. short text which is declared in php file as strlen($text) and we've also full text of article which is too declared in the same file as $shorten.
so both of them (short text and full txt) has the same style for title<h2>title</h2>.
But i want title of full text to be different with the short one in style means it should has another delaration stylesheet.


Logged
“Fifty years of programming language research, and we end up with C++?”

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: home articles's title to be Different with other.
« Reply #5 on: September 30, 2012, 01:56:16 PM »

No, I think I understand completely. What the Body ID should do, & the CSS style to target the article header.

Code: [Select]
<body id="category-XYZ">
<h2>Title</h2>
<p>Text</p>

<h2>Target Title</h2>
<p>Text</p>

<h2>Title</h2>
<p>Text</p>
</body>

#category-XYZ h2 {
styles
}

Code: [Select]
<body id="target-article">
<h2>Target Title</h2>
<p>Text</p>
</body>

#target-article h2 {
styles
}
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: home articles's title to be Different with other.
« Reply #6 on: September 30, 2012, 02:00:17 PM »

The simple way is to upgrade to 1.7, then you'll get exactly what you want without having to dig through the code. (In 1.7 there are two separate code blocks for the title, depending on the type of view, so on index pages - e.g Home and category indexes - you get <h2 class="big">title</h2> while on full article pages you get <h2>title</h2>. It was actually supposed to be the other way around, but nevermind. This means that you can easily just add a style for the class "big" that makes it different from normal <h2>'s, and boom. Done. But that's in 1.7.)

If you want to do the same in 1.6, at least in the official version, you'll need to code in a filter within the title code, something like the following pseudo-code

Code: [Select]
if ($r['displaytitle'] == 'YES') {
    if(!empty($currentPage)) {
    echo '<h2>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h2>';
} else {
    echo '<h2 class="title_css">'.$title.'</h2>';
}
}

Please note that this is untested code so be sure to make a backup of your files before testing. Or, just upgrade to 1.7. ;)
« Last Edit: October 01, 2012, 11:05:45 PM by Fred K »
Logged

adminphp

  • Full Member
  • ***
  • Karma: 4
  • Posts: 150
  • you must be a great snewser .
Re: home articles's title to be Different with other.
« Reply #7 on: September 30, 2012, 07:46:33 PM »

very simple, great work fred K it works perfect.
here is the feed +karma for you. ;D
Logged
“Fifty years of programming language research, and we end up with C++?”

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: home articles's title to be Different with other.
« Reply #8 on: October 01, 2012, 11:06:33 PM »

Happy to help. Glad it worked. And thanks for the karma. ;)
Logged