Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2011-02-02 05:44:12

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

Re: Returning current article id/active article

Hi there,

what can i do to display the active class, even if i access an article only as a non-individual one?

EXAMPLE
i have content code like this in a section called lala:

<div id=“lala_content”>
<txp:if_individual_article>
<txp:article limit=“1” />
<txp:else />
<txp:article_custom id=“2” />
</txp:if_individual_article>
</div>

and in a sidebar navigation i got this to mark the active article:

<txp:rvm_if_this_article><li class=“active_article”><txp:else /><li></txp:rvm_if_this_article>
<i><span class=“entry-title”><txp:permlink><txp:title /></txp:permlink></span></i></li>

This attaches the active class to the navigation entry correctly, as long as i access the article individually.

As soon as i manoever to the section without appending an article url-title in the URL (resulting in displaying the article with ID 2)
no active class for the first article in the navigation (which is ID 2) is displayed.

I get the same result, when instead using server variables.

Thank you very much for any suggestions.

Last edited by jayrope (2011-02-02 07:14:16)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#26 2011-02-02 11:53:51

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Returning current article id/active article

The point of article_custom is that it displays a list with no relationship to global article context. That works in both directions; the fact that you are displaying article #2 somewhere on the page using article_custom does not make it “active” in any general sense.

BTW you can use if_article_id instead of rvm_if_this_article, if I am correctly understanding what rvm_if_this_article does.

Is the navigation list based on article_custom?

BTW even though your scenario fits with the existing topic, it’s an old topic and you’re asking a new question pertaining to it — better to open a new topic.


Code is topiary

Offline

#27 2011-02-02 20:31:03

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Returning current article id/active article

jayrope wrote:

and in a sidebar navigation i got this to mark the active article:

<txp:rvm_if_this_article><li class="active_article"><txp:else /><li></txp:rvm_if_this_article> <i><span class="entry-title"><txp:permlink><txp:title /></txp:permlink></span></i></li>

What you want can be done, but how to do it depends on the code you are using for the navigation (using article_custom, section_list, something else?). Can you post the entire code of the navigation list?

Offline

Board footer

Powered by FluxBB