Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Adding code to an article/page title  (Read 2090 times)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Adding code to an article/page title
« on: October 03, 2007, 02:01:37 pm »

I have an idea. Sometimes I'm in need of adding a simple code bit to the article title. Like an image for example.
Normally I'll just circumvent the default title by not making it visible and instead hard coding the title in the article body ... but then, a client wants similar functionality or as in this particular case I don't want to break the article structure/layout just because of that small addition (structure=title, date line, body, etc.)

So I'm thinking that a simple if-else statement in the article title function in center() should do. With more or less the same behaviour as the include button? (In admin panel, new article posting: title field, then to the right of it a radio box labelled "add HTML code" or something similar. When radio is selected, up flies a dialog with an area for code input. Ok the input, box closes, move to body area, tap-tap-tap, done. Simple.  :o

I don't really have the time today to figure out the exact code for this, which would be absolutely smashing imho, so I'm asking for help from any of the code savants, em, gurus here. Pretty please?

Thanks a bunch.
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Adding code to an article/page title
« Reply #1 on: October 16, 2007, 06:44:35 am »

[bumpeti-bump]

Ok, I know that this
Quote from: me
a simple if-else statement in the article title function in center() should do.
isn't entirely true ... the functionality requires more than that, which is partly why I'm stuck. Partly, also, because I don't know much PHP. There, I said it (again).

No-one wants to help? Please?
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: Adding code to an article/page title
« Reply #2 on: November 12, 2007, 05:02:31 pm »

Also I try to find solution for this
In clickable article
Code: [Select]
echo '<h2>'.(!$article || $currentPage ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h2>';
If I change it to
Code: [Select]
echo '<h2>'.(!$article || $currentPage ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'
.'<img src="any-image.jpg" />'.'</a>' : $title).'</h2>';

Display the image and when you click display the title,
so the only thing is needed is to pass  . '<img src="any-image.jpg" />'.  instead  of .$title.
But I donít have find how to pass the img  ???
« Last Edit: November 12, 2007, 05:04:53 pm by sibas »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Adding code to an article/page title
« Reply #3 on: November 12, 2007, 06:02:15 pm »

Interesting mod idea Agentsmith. I'd work on it but I'm also short on time at the moment.  :)
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: Adding code to an article/page title
« Reply #4 on: November 19, 2007, 02:39:22 pm »

sibas,

I'm not entirely sure how to go about this --I think it requires an AJAX/javascript solution-- because what needs to happen is this:

1. Enter the title as normal.
2. Click control that says "Edit title". This should bring up a box with a textfield that is prepopulated with the generated SEF, wrapped in <h2> (or whatever you've set in the title call in center(); ) tags, so you can edit it -- add code or whatever -- plus a submit button ("Commit change" or something like that).
3. Write article as normal.

At least that's how it works inside my head. Now, to make it into actual code... [insert appropriate emotional sound or gesture or both]
Logged