Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-02-21 17:49:59

sambooth74
Member
From: Leeds, England
Registered: 2020-11-24
Posts: 18
Website

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

#2 2021-02-22 06:47:12

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

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

#3 2021-02-22 07:53:02

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

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

#4 2021-02-22 09:13:07

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

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 and html_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

#5 2021-02-22 09:22:51

sambooth74
Member
From: Leeds, England
Registered: 2020-11-24
Posts: 18
Website

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 global class and html_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

#6 2021-02-22 09:45:36

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

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

#7 2021-02-22 10:04:07

sambooth74
Member
From: Leeds, England
Registered: 2020-11-24
Posts: 18
Website

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 and html_id to older/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

#8 2021-02-22 10:04:58

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

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

#9 2021-02-22 10:09:31

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

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

Board footer

Powered by FluxBB