Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
A few tags have wraptag but not class
Working through the TextBook attribute lists, I came across three tags that have wraptag
but not class
:
Not surprisingly, the reason is that none of the three use doWrap()
to apply the wraptag
. Is it worth adding class
to these for the sake of consistency?
Code is topiary
Offline
Re: A few tags have wraptag but not class
jsoo wrote:
Is it worth adding
class
to these for the sake of consistency?
Don’t see why not. Added class to <txp:feed_link />
in this release so we might as well do the others. It’s only a couple of lines to change per function to add the class
attribute and swap the tag()
for doTag()
. Piece of cake, leave it with me.
EDIT: should the default be __FUNCTION__
or unset?
Last edited by Bloke (2010-10-06 21:55:29)
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
#3 2010-10-06 22:35:02
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: A few tags have wraptag but not class
Bloke wrote:
EDIT: should the default be
__FUNCTION__
or unset?
I wonder why for some tags it’s __FUNCTION__
and for others unset (Textbook).
From a non-coder POV I’d say either one or the other for all of them. Am I missing something?
Offline
Re: A few tags have wraptag but not class
Els wrote:
I wonder why for some tags it’s
__FUNCTION__
and for others unset
Pass.
Both systems have relative merits depending on the application but it’s a fine line. For instance, <txp:article />
and <txp:article_custom />
(which, incidentally, aren’t listed in the attributes cross-ref as taking class
, yet they do — must fix that one day) make sense unset because class="article_custom"
doesn’t add much meaning. Since both article and article_custom are really the same internal function they share attribute defaults, so that explains that one.
For tags like <txp:section_list />
though it’s kind of handy to have it set to the tag name by default so if you use a wraptag
you don’t have to type more to alter it from something fairly semantic; unless you absolutely feel the need. Maybe that’s the dinstinction? I haven’t checked, but perhaps if it makes sense (semantically) to use the tag name as a class it’s set to __FUNCTION__
otherwise it’s left unset?
*shrug* using that logic, link_feed_link
and search_input
should probably be set, while popup
should be unset. Does that work for everyone?
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 2010-10-06 23:16:22
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: A few tags have wraptag but not class
Bloke wrote:
I haven’t checked, but perhaps if it makes sense (semantically) to use the tag name as a class it’s set to
__FUNCTION__
otherwise it’s left unset?
Yes, I can follow that logic.
*shrug* using that logic,
link_feed_link
andsearch_input
should probably be set, whilepopup
should be unset. Does that work for everyone?
As you say, it’s a fine line. I wouldn’t know where to draw it exactly. Thanks for clarifying but I’ll leave it to you ;)
Offline
Re: A few tags have wraptag but not class
Great, I didn’t know doTag()
.
Added article
and article_custom
to the cross-ref.
Your decision on empty v. __FUNCTION__
makes sense to me.
Code is topiary
Offline
Re: A few tags have wraptag but not class
Done, thanks.
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
Re: A few tags have wraptag but not class
I just ran into a situation where I was trying to duplicate:
<a href="index.html" class="rssfeed">RSS Feed</a>
My first attempt where I noticed class was available but didn’t actually read the documentation was this:
<txp:feed_link class="rssfeed">RSS Feed</txp:feed_link>
and gave me:
<a href="http://cmsstyles.com/demos/urbanartist/rss/" title="RSS Feed">RSS Feed</a>
After actually reading the docs, I faked it with:
<txp:feed_link wraptag="span" class="rssfeed">RSS Feed</txp:feed_link>
and got:
<span class="rssfeed"><a href="http://cmsstyles.com/demos/urbanartist/rss/" title="RSS Feed">RSS Feed</a></span>
which was close enough as for the browser to figure out what I was going for.
Offline