Problem/Motivation

How would i go about making the Tab titles dynamic? Specifically, each tab has a view in it and i want the tab title to include the number of results in that tab's view. My guess is i would need to make a new plugin? Any hints?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

liquidcms created an issue. See original summary.

liquidcms’s picture

Title: Dynamic tabs, » Dynamic tab titles
liquidcms’s picture

I think I am close. I extended the ViewsTab class and removed the parts i didn't need. In the getContent() method i can see $this->title as the default tab title and using $this->title = 'XXX' or $this->setTitle('XXX') i can see in the code this value is changed - but it has not impact on the title/label.

liquidcms’s picture

Hmm, not setTitle(), but getTitle() can be overridden to return a different title. But it runs before the content of the tab is run. I can rerun the view again but less efficient to run it twice. I guess i could redo the getContent() to grab from cache stored during getTitle; but seems wrong.

liquidcms’s picture

no, getTitle doesnt work either as it just adds to the stored value every time the config page (or possibly view page) is hit.. so tab titles ends up as My title (10) (10) (10) (10) after a while.

TMurray’s picture

Would be really useful if this tab totals feature could be built directly into the module.

g089h515r806’s picture

You can do it with JS and CSS.
1.Display the total number in the tab view, hide it.
2.Using js display the total number to title.