Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-04-29 03:26:19

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

Renaming a section... why so hard?

If I want/need to rename a section I can rename the Title and that fixes the display fine. But this doesn’t reflect in the url or any references to that section I may have used in tags on my pages or in my forms etc – for this I need to use something like smd_where_used

This isn’t ideal when building sites for users who expect this kind of ease of content editing.

Is there a way to do this I don’t know of using native tags?

If not – is there a chance that an section_id attribute (or something else as i know Jukka mentioned some “way above my head” reason for not using ids) can be added to all relevant tags (section, section_list, article, article_custom, category etc).

Offline

#2 2013-04-29 04:20:17

agovella
Member
From: Houston, TX
Registered: 2005-05-01
Posts: 66
Website Twitter

Re: Renaming a section... why so hard?

I am able to change a section’s name and title fields. In your references to the section, are you using the <txp:section> tag, or are you hard-coding the section name and URL in your HTML?

http://www.textpattern.net/wiki/index.php?title=section

Offline

#3 2013-04-29 04:31:49

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

Re: Renaming a section... why so hard?

an example <txp:section_list sections="name1,name2,name3,name4" />

In the txp admin area Presentation —> Sections: if I change the title Name and Title of “name1” to “noname1” it no longer shows in my section list.

If that was referenced as <txp:section_list section_ids="1,2,3,4" /> (section_ids doesn’t exist… yet) then all would be good :)

Its not a good solution for everyone, but then again neither is using names – so including both would cover all bases… imho of course

Offline

#4 2013-04-29 08:08:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,794
Website GitHub

Re: Renaming a section... why so hard?

I guess the primary reason for using names is that, once you have set the site up, the sections form part of the URL. Changing them may affect your search engine results and leads to 404s unless you take intervention steps like adding redirects. That’s true of article url-title as well I suppose, and permlink scheme, but I’d guess they won’t change often either.

If you train your users in the art of “every time you change a section name, make sure you add a redirect by doing such-and-such” then that’s cool, but it’s burdening the user with more stuff to remember. The simplest approach is to warn them off trying to do it.

That said, I know during development, I sometimes go “dang, I wish I’d named this section something else” and have to hunt for all places I’ve used it. If you think this might be the case and want a layer of abstraction above your page template you can set up a load of txp:variables in a form that you pull into your page at the very top of your templates using <txp:output_form>. In that form, you can group section names into logical sets or even define your own section IDs:

<txp:variable name="section_1">iron-man</txp:variable>
<txp:variable name="section_2">black-widow</txp:variable>
<txp:variable name="landing_pages">news, iron-man, black-widow, hulk, captain-america</txp:variable>

and then use those in your templates:

<txp:section_list sections='<txp:variable name="landing_pages" />' />

or

<txp:if_section name='<txp:variable name="section_1" />'>
blah blah
</txp:if_section>

You can even use your section_1, section_2 variables in later txp:variable definitions in the included form if you wanted, to build up things like the landing_pages variable so you really do only need to change them once in one form if you rename your sections.

OK, it’s not quite native IDs, but it works.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2013-04-30 00:46:12

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

Re: Renaming a section... why so hard?

Thanks Stef – that looks workable, although I was looking for something a little easier :(

I just had 3 clients on the trot ask for section changes as they had stopped offering services in that sector, but some of the information and pages was still relevant, (all accused me of trying to rip them off for something, in their eyes, so simple)…. ah well

I might even look to see if this is doable as a plugin… you know, dust off my ailing and failing php skills :)

Offline

Board footer

Powered by FluxBB