Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Newer and older tags not accepting class or html_id
Hi,
I’m using the newer and older tags but I can’t get the class or html_id to work.
Here’s my code:
<txp:evaluate test="newer,older">
<nav class="sb74-pagination" aria-label="<txp:text item="page_nav" />">
<txp:newer rel="prev" class="sb74-button">
<txp:text item="newer" />
</txp:newer>
<txp:older rel="next" class="sb74-button">
<txp:text item="older" />
</txp:older>
</nav>
</txp:evaluate>
Here’s the HTML output:
<nav class="sb74-pagination" aria-label="Page navigation">
<a rel="prev" href="https://sb74.net/preview/">
Newer
</a>
<a rel="next" href="https://sb74.net/preview/?pg=3">
Older
</a>
</nav>
As you can see, the class is not being applied to the newer and older links.
Am I doing something wrong? Many thanks in advance.
Offline
Re: Newer and older tags not accepting class or html_id
I think that class
is not a supported attribute. You could though do this:
<txp:evaluate test="newer,older">
<nav class="sb74-pagination" aria-label="<txp:text item="page_nav" />">
<div class="sb74-button">
<txp:newer rel="prev">
<txp:text item="newer" />
</txp:newer>
</div>
<div class="sb74-button">
<txp:older rel="next" class="sb74-button">
<txp:text item="older" />
</txp:older>
</div>
</nav>
</txp:evaluate>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Newer and older tags not accepting class or html_id
class
and html_id
are global, so it should work. Unless the tag itself is overriding this behaviour for some reason.
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: Newer and older tags not accepting class or html_id
colak wrote #329012:
I think that
class
is not a supported attribute.
Bloke wrote #329013:
class
andhtml_id
are global, so it should work.
It would, if you supplied wraptag
attribute. For example, with ...<txp:newer rel="prev" wraptag="div" class="sb74-button">...
you’d get what Yiannis suggests.
Without wraptag
, the global class
and html_id
have no idea where to apply themselves.
Offline
Re: Newer and older tags not accepting class or html_id
etc wrote #329016:
It would, if you supplied
wraptag
attribute. For example, with...<txp:newer rel="prev" wraptag="div" class="sb74-button">...
you’d get what Yiannis suggests.Without
wraptag
, the globalclass
andhtml_id
have no idea where to apply themselves.
That explains it, thank you. However I’m now getting 2 A tags.
<a class="sb74-button">
<a rel="next" href="https://sb74.net/preview/?pg=2">Older</a>
</a>
Is there any way of telling TextPattern to apply the class attribute to the same A element as the rel attribute?
Offline
Re: Newer and older tags not accepting class or html_id
sambooth74 wrote #329018:
However I’m now getting 2 A tags.
With wraptag="a"
?
Is there any way of telling TextPattern to apply the class attribute to the same A element as the rel attribute?
No, I’m afraid. Global wraptag
is completely agnostic of what it is wrapping. You can try
<txp:evaluate test="evaluate">
<nav class="sb74-pagination" aria-label="<txp:text item="page_nav" />">
<txp:evaluate test="newer"><a rel="prev" class="sb74-button" href="<txp:newer />">
<txp:text item="newer" />
</a></txp:evaluate>
<txp:evaluate test="older"><a rel="next" class="sb74-button" href="<txp:older />">
<txp:text item="older" />
</a></txp:evaluate>
</nav>
</txp:evaluate>
If we have time before 4.8.5 release, I can try to add proper class
and html_id
to older/newer
tags.
Offline
Re: Newer and older tags not accepting class or html_id
etc wrote #329021:
With
wraptag="a"
?No, I’m afraid. Global
wraptag
is completely agnostic of what it is wrapping. You can try
<txp:evaluate test="evaluate">...
If we have time before 4.8.5 release, I can try to add proper
class
andhtml_id
toolder/newer
tags.
That solved my problem, many thanks. Hopefully after a few more months of using Textpattern, I will understand the software enough to fix some of these issues myself. I feel like I am still learning the basics, and me creating my own theme will be a good way to understand the Textpattern way of thinking.
Thanks again.
Offline
Re: Newer and older tags not accepting class or html_id
Meanwhile you can try etc_attribute. Adding class="a"
to its preference should make your original code work.
But then be careful to call global wraptag
before class
in attributes when both are needed.
Offline
Re: Newer and older tags not accepting class or html_id
sambooth74 wrote #329024:
Hopefully after a few more months of using Textpattern, I will understand the software enough to fix some of these issues myself. I feel like I am still learning the basics, and me creating my own theme will be a good way to understand the Textpattern way of thinking.
You are welcome. Textpattern is a mix of legacy code with more recent additions. For bw-compatibility reasons, not everything is completely uniform yet.
Offline