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.

Pages: 1 [2] 3

Author Topic: [MOD] The Body ID, for sNews 1.6  (Read 12492 times)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] The Body ID, for sNews 1.6
« Reply #15 on: November 18, 2007, 02:58:25 pm »

Quote from: Sven
I still don't get how to use the Body Id Mod with ONE template

It's not so difficult. Maybe you're overthinking it?

1. Put mod in snews.php
2. Replace normal start <body> tag in index.php with <?php bodyname(); ?>
3. Add some styles for your pages and categories to make them different. Example:
Quote
body { background:white; color:black; }
#administration { background:pink; color: white; }
#contact { background: black; color: lime; }
#design { background: purple; color: aqua; } /* Provided you have a page/category called design... */
4. Let sNews do the rest ...

As for the description thing, I defer to the PHP Masters.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MOD] The Body ID, for sNews 1.6
« Reply #16 on: January 10, 2008, 02:26:47 am »

@ Fred... This mod is amazingly useful for minor template style changes and works well with Bakercad's template switch mod as well. I wonder... have you given any thought to making another version of the bodyname function that would switch from one css stylesheet to another based on bodyname? The reason I ask is... doing a complete stylesheet switch would let us change the layout by category (as an example) much more extensively. One could craft a half-dozen stylesheets, cloned on the primary (default) stylesheet, and have more room to play.   :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

centered

  • Guest
Re: [MOD] The Body ID, for sNews 1.6
« Reply #17 on: January 10, 2008, 03:01:23 am »

@ Fred... This mod is amazingly useful for minor template style changes and works well with Bakercad's template switch mod as well. I wonder... have you given any thought to making another version of the bodyname function that would switch from one css stylesheet to another based on bodyname? The reason I ask is... doing a complete stylesheet switch would let us change the layout by category (as an example) much more extensively. One could craft a half-dozen stylesheets, cloned on the primary (default) stylesheet, and have more room to play.   :)

You can do everything in the stylesheet.  Fred gave a perfect example of a basic style based on categories and pages.  As long as the body has an id you can do the rest

#page .header h1 a
#page .header .menu ul
etc etc
#category .sidebar ul li a { }
etc etc
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MOD] The Body ID, for sNews 1.6
« Reply #18 on: January 10, 2008, 03:54:45 am »

You can do everything in the stylesheet.  Fred gave a perfect example of a basic style based on categories and pages.  As long as the body has an id you can do the rest
Yes... I know. I've used it a good bit for minor changes between categories. However, I suppose I could having a dozens sets of style declarations for a dozen categories all in one hudge stylesheet.... guess I'll just have to push the limit and see where it goes.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] The Body ID, for sNews 1.6
« Reply #19 on: January 10, 2008, 08:24:27 am »

Key-- I haven't thought much about doing a styleswitcher based on body id, mostly because it seems (in most cases) not necessary. Apart from what equilni already said, you can also create many stylesheets, one for each body id, and then include them all in index.php:

Quote
<head>...
<link rel="stylesheet" type="text/css" href="styles/page.css" />
<link rel="stylesheet" type="text/css" href="styles/category.css" />
<link rel="stylesheet" type="text/css" href="styles/home.css" />
<link rel="stylesheet" type="text/css" href="styles/contact.css" />
...</head>

The only thing to keep in mind is to be explicit in your stylesheet rather than implicit, so instead of just going "p {style: here;}" you would do "#page p {this.style: here;}", etc.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MOD] The Body ID, for sNews 1.6
« Reply #20 on: January 10, 2008, 03:28:51 pm »

Apart from what equilni already said, you can also create many stylesheets, one for each body id, and then include them all in index.php:
The only thing to keep in mind is to be explicit in your stylesheet rather than implicit, so instead of just going "p {style: here;}" you would do "#page p {this.style: here;}", etc.
I just gave this a try (preliminary test) and it does work... so my question is answered. Theoretically speaking... I should be able to use CSS to block some elements from displaying in some css files as well... (more testing...)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Kan

  • Newbie
  • *
  • Karma: 0
  • Posts: 22
Re: [MOD] The Body ID, for sNews 1.6
« Reply #21 on: April 22, 2008, 03:27:21 am »

People. Very respected people. I could not take it anymore, so i've  registered at the forum and I'm saying what I want to say. Firs of all, of course many thanks and so on and so forth...
People! Do something with this disorder! I am using Snews, so I am reading this forum in search for necessary mods. And to find what I want i must read ALL posts in all threads concerning the things in which I'm interested. Because the important things about thread-starting-mods are dissipated thru all the thread, and not collected in one post. Is it so difficult to establish the hard rule to developers  - to OBLIGATORY update the FIRST post with all new corrections and additions??
And very often it's absolutely unclear what this or that mod exactly makes. And very often it is absolutely mistful, how to use this or that mod exactly.
Try to understand, dear 3-5 respected developers, that you make it all for the whole world, and the "simple people", the users very often don't understand the things which are new to them, though are obvious for you. Why not to make another rule for mod publishers - to explain exactly, if possible - with examples - what their mods do and how to deal with these mods exactly. And maybe it makes a sence to make a special separate forum\site section with the ready to use mods and the clear explanation?
I am saying it all because I spent not one hour today to catch how to make my snews-generated pages look slightly different when I want it, I don't care by what means - by different .css files or somehow using the same .css file. And till now I have got only the half of information. I got it from this thread. What I got:
1 - how to implement body-id to the snews.php and to the index.php
2 - i have got not. - what-exactly-can-I-do-with-it, what-should-I-do-next-to-see-what-I-want.
I am continuing my search...
To be more concrete to my case: I need two differents styles. First - for my 100 different categories, and second - for my 1000 different articles in these categories. I don't see the clear way to have what i want. By the way, this body-id mod makes the same id for the whole category, and I want different styles for "category" and for "inner articles". Maybe I'm looking at the wrong place, and I need some other mod. But it makes even more sense to the fact that here rules the total disorder at the forum.
Thak you for understanding.
Logged

Kan

  • Newbie
  • *
  • Karma: 0
  • Posts: 22
Re: [MOD] The Body ID, for sNews 1.6
« Reply #22 on: April 23, 2008, 02:48:01 am »

...and I've found the solution. For my personal problem. Thanking mosh here.

http://snewscms.com/forum/index.php?topic=7292.0

..and Keyrocks here http://snewscms.com/forum/index.php?topic=5323.msg51589#msg51589

Thanks to all good people. It was really hard to find the solution by myself, without asking for help (what I always do as a last thing)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] The Body ID, for sNews 1.6
« Reply #23 on: April 23, 2008, 03:14:32 am »

Sorry if I've caused problems for you Kan, certainly not intentional. As far as I know, the first post contains the correct code for 1.6. I'll go through it of course, but, at least the last few posts in this topic deals with certain aspects of how-to-use the body id which doesn't really affect the code as such. Certainly, when I wrote the first post I thought I was being very clear about what it does ("adds an id to the body tag") and how to use it ("replace the normal <body> tag in index.php, replace it with the function <?php bodyname(); ?>") as well as showing what it generates ("<body id="very-respected-people">"). So, if you get a dynamic id attached to the body tag, what can you do with it? Paint the body blue. Paint every headline on that particular body red. Make very image on that particular body extremely tiny, while they can be extremely large on another "page". It's all just CSS, and that is how you use the body id. Actually, how you use it is very much up to your imagination, I don't expect I could even begin to cover all possibilities that are opened up with this mod. But most of them apply to styling.

Again, sorry for the extra work. Maybe I'm too close to the mod to see the descriptions as unclear. Glad you found the answers you needed though, that's what the forum is for.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MOD] The Body ID, for sNews 1.6
« Reply #24 on: April 23, 2008, 03:40:30 pm »

People. Very respected people. I could not take it anymore, so i've  registered at the forum and I'm saying what I want to say. First of all, of course many thanks and so on and so forth...
People! Do something with this disorder!
To find what I want i must read ALL posts in all threads concerning the things in which I'm interested.
And very often it's absolutely unclear what this or that mod exactly makes.
Why not to make another rule for mod publishers - to explain exactly, if possible - with examples - what their mods do and how to deal with these mods exactly. And maybe it makes a sence to make a special separate forum\site section with the ready to use mods and the clear explanation?
Thak you for understanding.

Thanks for sharing your insights as a relatively new Forum member Kan. Even some of us who have been with sNews for a couple years now have problems finding topics and posts when we need them... an unfortunate situation when using a Forums system that has a lot of daily activity. The approach used to date has been to allow any and all Forum members the freedom to share their modifications with everyone else. I believe there are (in most Forum sections) Sticky or Locked topics at the start of each section explaining how we'd like Members to post their mods... like This One...but not everyone takes time to "read them first".  :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: [MOD] The Body ID, for sNews 1.6
« Reply #25 on: April 24, 2008, 03:41:25 pm »

...And maybe it makes a sence to make a special separate forum\site section with the ready to use mods and the clear explanation?
Well, the ready to use (with clear explanation) place is the mod forum.
Developing mods should be in programming.

There was talk behind the scenes of seperating out working, and objectively good/handy, mods, and having them remote from the forum, but, then it became a matter of who maintains it. If we put it onto snewscms, then those who look after that site (other than this forum), would be obligated to maintain, adjust, upgrade those mods. It is far better leaving this in the hands of the original poster --- hence, mods remain on the forum, with only links to some of them on snewscms.
Logged
Of all the things I have lost, it is my mind that I miss the most.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] The Body ID, for sNews 1.6
« Reply #26 on: September 28, 2009, 04:27:23 pm »

Preamble: Back in the day, e.g. v1.5, there was some demand for a mod that allowed us to change styling of pages on the fly. The simplest, most dynamic way of doing that for the webmaster (note: not the visitors, not the site admin when that is different from the webmaster) is by assigning an id to the <body> tag, based on the active page name. So I created such a mod for v1.5 with much help from philmoz. Here is the same code for v1.6.(...)
Guess what?
This terrifying Mod has not been ported to 1.7 version. ;D
Any volunteer to give a hand since I don't get at all how to?

Creatium

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 55
Re: [MOD] The Body ID, for sNews 1.6
« Reply #27 on: September 28, 2009, 07:12:01 pm »

Yeah... Maybe this mod "father" could make one code for sNews 1,7? Coz with this code i get blank page.
Logged
Aurea praxis, sterilis theoria.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] The Body ID, for sNews 1.6
« Reply #28 on: September 28, 2009, 09:33:50 pm »

Yeah... Maybe this mod "father" could make one code for sNews 1,7? Coz with this code i get blank page.

Well, (1) I don't have a real need for it and there hadn't been any calls for a 1.7 version until now so that's most likely why it hasn't been ported to 1.7 before; (2) the mod code was very generously given to me by philmoz (I just published that code here for the benefit of others) so in all honesty I wouldn't know exactly how to port it to 1.7 and since I don't really use it anymore ... I haven't bothered trying; and (3) there are a number of changes and additions in the core from 1.6 to 1.7 as you know, so porting this mod may take some work. I don't really know since I don't really need it, hardly ever use it and don't really have the time or inclination to port it.

Anyone who wants to convert it to a 1.7 mod, please do.
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] The Body ID, for sNews 1.6
« Reply #29 on: September 29, 2009, 05:53:58 am »

Hard to code, easy to use! You're damned right.
Making simple for the user is often complicated for the coder.
That body ID trick should be a feature of sNews future versions.
Is there someone interested in a <body><body> experience? ;D
Pages: 1 [2] 3