Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
<txp:section /> as a container tag to generate custom links to section
Hi, I was looking for a way to generate a link to a section, but with some custom text.
There are more than one way:
- <code><a href=”<txp:site_url /><txp:section name=“contact” />”>Feel free to contact us</a></code>
- <code><a href=”/<txp:section name=“contact” />”>Feel free to contact us</a></code>
Too much code! (no, not too much really but…).
The feature request is:
the option to use txp:section also as a container tag
So, you can code something like:
<code><txp:section name=“contact” link=“1”>Feel free to contact us</txp:section></code>
Or even better:
<code><txp:section name=“contact”>Feel free to contact us</txp:section></code>
In this second case, TXP should understand that the tag is being used as a container, so automatically generate the link to the section, without needing to specify the link="1"
attribute (so, you wont need to remember to specify that attribute when using the tag as a container, and also, I think that there isnt another reason to wrap some text with txp:section that try to generate a link to that section).
Possible uses:
For that people that love to write a section nav as a paragraph, customising the link text, like:
“Hi, I’m Cocoloco, read my <a href=”#”>collection of tutorials</a>, or check out <a href=”#”>my portfolio (under construcion)</a>. Also, feel free to <a href=”#”>drop me some lines</a>. And of course, read <a href=”#”>more about me, my cat and how this site is powered</a>.
That, with txp:section as container, could be coded as:
<code>Hi, I’m Cocoloco, read my <txp:section name=“tutorials”>collection of tutorials</txp:section>, or check out <txp:section name=“portfolio”>my portfolio (under construcion)</txp:section>. Also, feel free to <txp:section name=“contact”>drop me some lines</txp:section>. And of course, read <txp:section name=“about-me”>more about me, my cat and how this site is powered</txp:section>.</code>
That’s all!
Last edited by maniqui (2005-12-06 05:49:46)
Offline
Re: <txp:section /> as a container tag to generate custom links to section
What if zem_link provided this feature by means of three new attributes (section
, category
, author
), thus introducing article list mode links to zem_link?
One could use a markup like that: <txp:zem_link section="fruit" category="apples" author"eve">taste this, adam!</txp:zem_link>
and achieve links like that http://www.example.com/fruit/?c=apples&author=eve
. Attributes would be combinable at will.
Would that fulfill your needs?
//w&
Offline
Re: <txp:section /> as a container tag to generate custom links to section
Hi wet,
I dont use zem_link, but what you suggest would be a nice improvement in the plug-in for those who use it, and yes, it will fulfill the needs (the truth: I asked the feature, but I dont need it… yet).
Maybe, that improvement should be suggested in zem_link thread.
Also, I would go more for a simple little improvement of built-in txp:section: again, the option of using it as a container tag, just to generate a link (with custom text) to a section.
Offline
Re: <txp:section /> as a container tag to generate custom links to section
I give this a bump.
I have found some questions about how to link an article title (usually sticky) to the section it belongs, and not to the permalink (or URL-title).
That “how do I” is usuarlly related to search results and sticky articles, when the developer wants that the sticky article (in the results) links to the section, not to the article.
That’s when the idea of <txp:section></txp:section>
as a container tags could become useful in an article form.
Something like <txp:section><txp:title /></txp:section>
That “snippet” will be sensitive to the article section and then generate a link to the section.
That’s all. Just a bump.
Offline
Re: <txp:section /> as a container tag to generate custom links to section
As a navigation tool, I think most of us would need a lot more of customization. I would suggest two tags (or attributes) :
- One to display the name (sorry, title) of a section
- One to display a link to that section
Another concern, is when you don’t want to have to know what sections are around, or don’t want to edit your nav code when a section is edited/added/removed. In that case, for the kind of flexibility needed, I can only think of a double level code : a tag, and a form. The form would be used for each occurence of a section.
Before I expand on the subject, this is an example of a would-be common nav code :
<div id="navigation-sections">
<h3>Main navigation</h3>
<ul>
<li><a href="mysite.tld/" title="Back to home">Home <span>Some chitchat about home</span></a></li>
<li><a href="mysite.tld/articles" title="My pretty articles">Articles <span>Some chitchat about my articles</span></a></li>
<li><a href="mysite.tld/about" title="About me and my cat">About <span>Some chitchat about about, yes it's english</span></a></li>
</ul>
</div>
That’s the kind of code needed to be achieved.
So there’s a lot of things needed, as custom : the whole container and class/id, the header level, the header text, maybe the type of list used, both the section’s title and url of course, and a lot of personnal html code.
It’s mainly easier to code it by hand, but that won’t work if you (or your client) move your site around a lot, or more important if you are creating a theme for TXP.
Offline
Re: <txp:section /> as a container tag to generate custom links to section
Jeremie wrote:
As a navigation tool, I think most of us would need a lot more of customization. I would suggest two tags (or attributes) :
- One to display the name (sorry, title) of a section
- One to display a link to that section
Hi Jeremie.
I’m not sure if I understood you.
Those attributes do already exist:
<txp:section name="about" title="1" link="1" wraptag="li" />
will output something like:
<li><a href="/about">About us</a></li>
Another concern, is when you don’t want to have to know what sections are around, or don’t want to edit your nav code when a section is edited/added/removed. In that case, for the kind of flexibility needed, I can only think of a double level code : a tag, and a form. The form would be used for each occurence of a section.
Yes, that would be great. Some kind of txp:section_list
on stereoids.
Maybe, also, in the Presentation->Section tab, a way to sort the sections, so txp:section_list would reflect that sorting.
Finally, about those <span></span>
in your section links: that could be achieved if section title accept HTML tags:
But I think that will lead to problems with <title></title>
as has been discussed before.
Last edited by maniqui (2006-03-16 06:32:30)
Offline
#7 2006-03-18 14:34:26
- marios
- Archived Plugin Author
- Registered: 2005-03-12
- Posts: 1,253
Re: <txp:section /> as a container tag to generate custom links to section
Not only <code><span></span></code> for the current selected section,
Others prefer <code><strong></strong></code>,
and the option for having the active section not being wrapped by anchor tags,
(Or at least a “no-show attribute” for the currently selected section)
“
plus the need to get the choice for the “current” or “active” attribute beeing wrapped in the list item by Textpatterns native doWrap function.
(EDIT.:This refers to the section_list tag)
regards, marios
Last edited by marios (2006-03-18 14:38:41)
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
Re: <txp:section /> as a container tag to generate custom links to section
I have found that most difficulties with respect to missing attributes or styling possibilities concerning sections can be deducted to the lack of:
- a form processing capability
- custom fields
- accompanying tags to employ those features
IMHO, the most general solution to all of these hassles would lead to an extrapolation of the way txp:article_custom handles articles to a similar tag handling sections, plus the addition of a handful of custom fields to the txp_section table.
Then, as a last goody, add nested sections: The future’s so bright you’ve gotta wear shades…
Offline
Re: <txp:section /> as a container tag to generate custom links to section
maniqui wrote:
I’m not sure if I understood you.
Those attributes do already exist:
<txp:section name="about" title="1" link="1" wraptag="li" />
will output something like:
<li><a href="/about">About us</a></li>
Yep, but it’s not granular enough. WHen you code something precise, you don’t need a “do-it-all” tag. You need to be able to output the raw name, title, and url. Some of these already exist, yep.
Finally, about those
<span></span>
in your section links: that could be achieved if section title accept HTML tags:
But I think that will lead to problems with<title></title>
as has been discussed before.
First of all, that’s a trick. I was commenting on a more elegant and clean solution :)
Second and mainly, this would have unfortunate side effect on other uses of section’s title. Sections’s titles are sections’s titles. span
tag (or other ones) in a navigation menu are an html trick for navigation. Not at all the same thing.
Offline
Re: <txp:section /> as a container tag to generate custom links to section
marios wrote:
Not only <code><span></span></code> for the current selected section,
Others prefer <code><strong></strong></code>
Yep, my code was an example of what needed to be achieved. The details (what tags, etc.) shoudl be left to the webmaster.
and the option for having the active section not being wrapped by anchor tags,
(Or at least a “no-show attribute” for the currently selected section)
plus the need to get the choice for the “current” or “active” attribute beeing wrapped in the list item by Textpatterns native doWrap function.
Indeed, I don’t know how I forget these.
So that’s two more need :
- Being able to add an
active
(-like) class to the active section’s context - being able to not place the hyperlinks on the active section list item
Or would these be a txp:if_active_section
or similar ? It’s more powerful, but it will bloat the page/form code.
Offline