Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-14 11:53:36

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Category Name/Title Question

I have another strange question :)

I have a site where I have set the category name & category title to be split into 2 different 2 css styles, <h> and <h2>.

So far I have used <h1><txp:category title=“1” name=“Fashion” /></h1> & <h2><txp:category name=“Fashion” /></h2> which produces the category title, and the categrory name.

But in my example there are duplicate category titles (Celeb News, Sports News, News News) and txp will not allow duplicates…

How can I get around this…. keeping in mind that article are called by the categories?

Offline

#2 2008-11-14 12:41:52

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Category Name/Title Question

I don’t get what it is you want to achieve, sorry. But here are two observations: 1. category (and section) names should always be all lowercase. If the names all consist of just one word, you can still display them with capitals using text-transform: capitalize;. 2. Are you sure that duplicate titles are not allowed? (I can imagine that it goes for names as those are part of the URL.)
But maybe if you can explain why you are displaying both name and title, I will understand your question better?

Offline

#3 2008-11-15 11:33:16

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Category Name/Title Question

Well the categories are styles like this:

FISHING News

So I am using these tags with The Category Name “Fashion” and the Category Title “Features” and styling them accordingly:

<h1><txp:category name=“Fishing” /></h1><h2><txp:category title=“1” name=“Fishing” /></h2>

What I am finding is that the category title cannot be used twice, so you can’t have “FISHING News”, CAMPING News” etc – txp says that it is already in use and doesn’t save my input.

Last edited by tye (2008-11-15 11:54:25)

Offline

#4 2008-11-15 11:54:34

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

Re: Category Name/Title Question

Hi tye

why not invert your choice:

category

name: Fiching Title: News
name: Camping Title: News
etc…

cause the name must be unique but the title is free!

Your first example not work, but your last code must work (e.g. category name diferent, but the same title)

Cheers.

Offline

#5 2008-11-16 02:24:13

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Category Name/Title Question

Thanks Dragondz – thats the solution I have been using… just wondering if there is a better way as it causes a slight confusion when choosing the category… just a slight one – but enough to annoy

Offline

#6 2008-11-16 15:18:29

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Category Name/Title Question

I’m guessing it might be possible to use PHP to add a span around the first word of the category title, so you can use CSS to style it the way you want.

Offline

#7 2008-11-17 01:45:26

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Category Name/Title Question

How would I do that Els?

Offline

#8 2008-11-17 16:37:23

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Category Name/Title Question

tye wrote:

How would I do that Els?

If I knew that I would have told you right away, honest :) I’m just assuming it can be done.

Maybe you should open a new thread, with a subject like ‘add span around first word using PHP’ (or edit this thread’s subject), that will probably attract the PHP gurus here ;)

Sorry I can’t tell you more than this…

Offline

#9 2008-11-17 22:29:43

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Category Name/Title Question

No worries Els – I’ve sorted this using the methods above – thanks anyway :)

Offline

#10 2008-11-18 19:53:13

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Category Name/Title Question

Just to throw my two cents in – you might think of using 2 categories. That is, an article in “FISHING news” could have Category1 set as Fishing, and Category2 set as News. Not sure if that makes things easier, but semantically it seems correct.
Do you have them separated just so you can apply a bold style to the first word? You could probably accomplish that with some JQuery.

Last edited by nabrown78 (2008-11-18 19:53:43)

Offline

#11 2008-11-18 22:29:50

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Category Name/Title Question

Hey Nora

Thats right – I have them separated so I can style them… can you point me in the right direction for learning how to do this using jquery please :)

I found this site http://docs.jquery.com/Tutorials is that a good start?

Offline

#12 2008-11-18 23:21:32

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Category Name/Title Question

Hi Tye,
Yes that is a good place to start as is the rest of the JQuery documentation. I am just learning myself, but I would think you would do something like (assuming your categories are in a list, for example, of class categories):

$(document).ready(function(){  
		$(".categories li").each(function(){ // for each item in the list
				var string = $(this).text().split(" "); // get the text and split into an array
				string[0] = "<span>"+string[0]+"</span>"; // surround the first word in the array with a span
				newString = string.join(" ") // put it back together
				$(this).html(newString); // set the new string as the html of the list item
	});  
});

Then you can style the span as you like!

In fact I did a little test – view the source of this page

Last edited by nabrown78 (2008-11-18 23:23:53)

Offline

Board footer

Powered by FluxBB