Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-06-19 11:03:43

Muphex
New Member
Registered: 2020-06-19
Posts: 3

Link formatting

Okay so I am trying to do the simplest of tasks and it’s annoying my why it won’t work (don’ they always). I am using txp:link_to_prev and next to create two buttons for navigating around articles.

Elsewhere on the site I have queried another SQL database and used the CSS as follows to essentially generate two “buttons”.

.prevnext { border: 4px solid #404040; background-color: #A0A0A0; color: black!important; padding: 5px; } (the !important was added out of desperation).

However no matter what I do I can’t change the links to blue, having looked at the generated HTMl I can see the txp code transformed into <a> links that I could do with formatting to fix the problem however no matter where I try to insert my “style=“color: black”“ it doesn’t show up in the subsequent code and the links remain blue.

Any help greatly appreciated.

Offline

#2 2020-06-19 11:23:00

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: Link formatting

Hi and welcome,

I hope I understood you correctly: you want the links that currently show in blue to be in black?

As it sounds like you have the correct anchor link to next / prev appearing in your code, Textpattern’s tags are probably working. So, two wild guesses:

  1. The link not taking on the style may be a css specificity problem. If you use the web developer tools / web inspector of your browser and then highlight the element on the page, it should show you which css declarations are determining it’s appearance. You many find you need to look a level deeper at anchor-link styles set for the next-higher container, or to prefix .nextprev with container element in your css, e.g. #content .nextprev { … } (assuming here that #content is the container).
  2. If you’re making edits to the Textpattern code but are finding that they don’t show on your public site, perhaps you are making changes in development mode but viewing the public side in another non-logged in browser (window)? Assuming you’re editing your code via the admin area, if your theme is set to development, you must be logged in to see the same output on the public side. The idea is that a developer can make and test changes without public viewers seeing them until you make your changes go live (see the sections / themes panel).
    If, on the other hand, you’re working from files rather than via the admin area, you need to import the theme changes to the database in the Presentation › Themes panel. If you are using flat files for theme development, etc_flat is a help: it will reference your theme files rather than the database when the site is in “testing” or “debugging” mode. When you are happy with your edits, you can import the theme from the files to the database and set your site to live. It basically speeds up development by avoiding the need to repeatedly import any changes you make to flat files.

Those are just two guesses and I could be way off :-) If you can post or show more, we can give you a more informed answer.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2020-06-19 13:07:53

Muphex
New Member
Registered: 2020-06-19
Posts: 3

Re: Link formatting

Thanks for that but I’m still at a bit of a loss. This iss tthe code from the buttons

<div style=“text-align: right;”> <hr> <span class=“prevnext”><txp:link_to_prev> Prev </txp:link_to_prev></span> <span>

and this is what it generates:

<span class=“prevnext”><a title=“Test Article 2” rel=“prev” href=“link to article”> Prev </a></span>

As the buttons are in a parent DIV I went ahead and applied the prevnext class to that but noe joy and alsoe tried manually coloringg the text tthere but again no joy. I also tried popping it in the sppan element both using class and manually on the element bu again not joy. I can see where the formatting needs to go in the <a> code but can’t get it there

Offline

#4 2020-06-19 13:24:57

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

Re: Link formatting

Hello, <txp:link_to_next /> does not support class attribute (as it probably should). You can

  • either modify your CSS selector like .prevnext, .prevnext>a { ... }
  • or install etc_attribute plugin and call <txp:link_to_next class="prevnext" ... />
  • or construct it manually:
<txp:link_to_prev link="">
    <a class="prevnext" rel=“prev” title=“<txp:title />” href=“<txp:permlink />”> Prev </a>
</txp:link_to_prev>

Offline

#5 2020-06-19 13:40:00

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: Link formatting

Good thinking Oleg/etc.

The underlying problem is still a CSS problem. As your anchor tag is inside the span with the class, you can try:

.prevnext > a { 
    border: 4px solid #404040;
    background-color: #A0A0A0;
    color: black;
    padding: 5px;
}

EDIT: Sorry Oleg, I didn’t see your first point where you said the same thing. Should have read more closely.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2020-06-19 13:59:24

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

Re: Link formatting

etc wrote #323847:

<txp:link_to_next /> does not support class attribute (as it probably should).

Is it easy to add support in 4.8.2? Although class is global, link_to() seems to do things internally a bit differently to other tags.


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

#7 2020-06-19 14:16:57

Muphex
New Member
Registered: 2020-06-19
Posts: 3

Re: Link formatting

etc wrote #323847:

Hello, <txp:link_to_next /> does not support class attribute (as it probably should). You can

  • either modify your CSS selector like .prevnext, .prevnext>a { ... }
  • or install etc_attribute plugin and call <txp:link_to_next class="prevnext" ... />
  • or construct it manually:

<txp:link_to_prev link="">...

Wonderful thank you the “> a” worked for me, such a small thing but it was driving me mad!

Offline

#8 2020-06-19 14:25:24

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,269
GitHub

Re: Link formatting

Muphex wrote #323850:

Wonderful thank you the “> a” worked for me, such a small thing but it was driving me mad!

You would not believe the number of times I’ve been caught out by a single character – happens waaaaay too often.

Offline

#9 2020-06-19 15:04:32

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

Re: Link formatting

Bloke wrote #323849:

Is it easy to add support in 4.8.2? Although class is global, link_to() seems to do things internally a bit differently to other tags.

Sure, it’s easy, but it would be on tags level. The global class works only with wraptag (global too), otherwise txp does not know where to apply it. Though in this case we could try to set class of the top-level HTML tag of <txp:tag /> output (à la etc_attribute) if we can detect it reliably.

Offline

Board footer

Powered by FluxBB