[solved] Line break in entry title?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
MarkMushakian
Regular
Posts: 16
Joined: Sun Apr 06, 2008 6:19 am
Location: San Clemente, CA, USA
Contact:

[solved] Line break in entry title?

Post by MarkMushakian »

I have an interesting question to pose - is it possible to create a line break within an entry's title?

The goal would be to create something visually similar to this:

Weekly Blog Series Name:
Individual Entry Title


The idea would be to have the ability to do this on each individual entry, as not all entries would require it. I have already tried all variations of the br html tag without luck, so I figured I would come here and see if anyone had any ideas. It's not an urgent thing, but it would be nice if it can be managed.

I suppose it could be done by creating If statements to allow for an entry's Category or Tag to be placed above the title for certain subjects, however at this point I'm unsure which of these systems I'll be using, if either.
Last edited by MarkMushakian on Sat Dec 20, 2008 7:41 pm, edited 1 time in total.
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Using your example, what is the source of the first line of text if the second line of text is the actual entry title?

I'm leaning to extended property fields where you could supply whatever text you wanted, and only for the entries you wanted, and if it exists, it is displayed in your 2 line example, and if it does not, it would just be the entry title... is that what you are thinking?
=Don=
MarkMushakian
Regular
Posts: 16
Joined: Sun Apr 06, 2008 6:19 am
Location: San Clemente, CA, USA
Contact:

Post by MarkMushakian »

Don Chambers wrote:Using your example, what is the source of the first line of text if the second line of text is the actual entry title?
So, I am working on a monthly blog series that will be titled "Second Chance Reviews" and I would have the title of what I am reviewing, whether a movie or book, as the second line. For example...

Second Chance Reviews:
The Notebook


The extended property field option you mention sound as if it would work for my purposes. Are you working on this in the form of a plugin, or by free-handing the code on individual files yourself?
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I sent you a PM, but in the event that does not reach you, I will try to explain.

Assumptions on my part: "second chance reviews" is a secondary title you might give to an entry. This text could vary by entry, or might not exist at all.

Next assumption: Entry title is "The Notebook".

If you have not already installed it, you need the plugin "Extended properties for entries". Once installed, it will default to having three custom entry property fields. I think they are "CustomField1, CustomField2, CustomField3" (or something like that). Either add another to that list, or replace one of them with your desired field.

So, lets either replace those 3 defaults with just "SeriesTitle", or add that name to the existing defaults: CustomField1, CustomField2, CustomField3, SeriesTitle. The name "SeriesTitle" can be anything you want, just modify what I write next to reflect the change in name if necessary.

Once you have this additional Extended Property Field, all entries will have the ability to specify it.

Next, we need to use it if specified. I have no idea what template you are using for your site. Your template will likely be located in /templates/whatever/, where "whatever" is the name of your template.

If that folder has a file named entries.tpl, great. If not, copy the file from /templates/default/ so that you have a unique version of this file for your particular template.

Again, not knowing what template you are using, we need to find out where/how the entry title is displaying.

In /templates/default/entries.tpl, the entry title is displayed as follows:

Code: Select all

<h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>
So, we have the entry title emitted as a hyperlink in the block-level <h4> heading element.

I do not want to get into the pro/con of which element you choose, so lets just place your custom text in a simple <div> above that. We can refine this as needed later on.

Here is what it might look like:

Code: Select all

{if $entry.properties.ep_SeriesTitle}
    <div class="series_title">{$entry.properties.ep_SeriesTitle}</div>
{/if}
<h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>
That code will check to see if the SeriesTitle field is not blank, and if not, will emit the <div> showing the actual text.... if blank, it will be skipped and proceed to the entry title. As a bonus, I also emitted the class of .series_title so you can style that in your template's stylesheet using the syntax of:

Code: Select all

.series_title{
...  insert your rules here ....
}
I did receive your PM response - contact me at your convenience as previously discussed.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

If it's all about linebreaks: You could write your title like "My headline|My subheadline" and later use {$entry.title|escape|replace:'|':'<br />'}.

Apart frmo that; don's conceptual comment is really something to think about and more advanced in the long run.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MarkMushakian
Regular
Posts: 16
Joined: Sun Apr 06, 2008 6:19 am
Location: San Clemente, CA, USA
Contact:

Post by MarkMushakian »

Don's solution was just what I needed! Thanks, as always, guys.
Post Reply