Forums / Cotonti / Support / How to display the chosen news category description on index?

foxhound
#1 2014-01-23 20:51

I am trying to display the choosen news category description on my index and I am not sure how I can retrieve it.
There is {PAGE_ROW_CATDESC} however to be able to use that you need to use it within the ROW block.
I need to output that value outside of the row block.

Is there a way for me to get the choosen new category description (so the description if you for example view this news: index.php?c=news_arma2oa_general on the index) to display on my homepage?

I was checking the php dump and I saw this: "{PHP.cot_cat.news_arma2oa.desc}" which actually outputs the correct value of that specific section. So, if any tag can not be used and I should use a PHP global, how can I use that one to dispal the category description depending on each section instead of just this one?


I could of course make 100 IF blocks (if I have 100 news categories) which check certain values and show specific data. I am just trying to find an easier way so that with maybe just one IF block I can get the value. Since adding 100 IF blocks in my honest opion really makes no sense I hope someone can tell me how I can achieve this.

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Twiebie
#2 2014-01-23 21:14

Use {PAGE_ROW_CATDESC} in your news.tpl file inside the PAGE_ROW block.

foxhound
#3 2014-01-23 22:19

Yes, I know I could use that. Problem is, I cant use it in the ROW block as I wrote above :)
I need to refer to the selected category in the index (or at least outside the page row in the news tpl cause I am displaying the category above a navigation menu. And we cant add that menu in the row block else we will see it above every news item.

I could use an IF statement so that if num == 1 I use the nav menu, but thing is....I plan to create the navigation menu in a different way and I am not sure that will still work if I add it to the news tpl ROW block. Thats why I was hoping I could create it differently.

I guess I will have to make some tries and see if I can follow my plan when adding it inside the ROW block :)

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Twiebie
#4 2014-01-23 22:46

Ah, sorry I misread that.

What exactly do you mean with ''I need to refer to the selected category in the index"?

Kort
#5 2014-01-24 08:26

Not sure if that is exactly what you need:

{PHP.structure.page.news.desc}

Alternatively you might be able to do the job via HTML-coding / jQuery

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#6 2014-01-24 10:01

@Twiebie

Ok, let me write a few examples to try and clear up :)
On the index.php we show all news (using the news plugin). However, since we have a constant news flow for many different categories during an entire day I have made a news selector. This allows people to output only news of a specific news category on the index.
So, by default people are on the index.php which outputs all news --> index.php?c=news
However, people might want to view all news of one category, for example, all Arma 3 news --> index.php?c=news_arma3
But, instead of viewing all Arma 3 news people can also select to view a specific sub category of the Arma 3 news, for example only Arma 3 addons and mods --> index.php?c=news_arma3_mods
Now, depending on these I want the news selector to show the choosen news category on the index.tpl where the news selector is made. Something like {PAGE_NEWS_CATDESC}  but that one does not exist.

This so people can "see where they are, which news they are currently viewing". {PAGE_ROW_CATDESC} does not work on the index.tpl so thats why I was looking for other tags or php globals. ;) I hope that makes more sense.

 

@Kort,
Yes I saw that one as well, but sadly it depends the category description of the news category only, and does not change automatically depending on where you are (while using it in index.tpl).

 

Alternatively you might be able to do the job via HTML-coding / jQuery

 

 

 

Maybe, but than I think an IF block inside the ROW is easier to work with. But that requires some testing first :)
I will give this some tries today/during the weekend but if anyone has a suggestion feel free to post them!

 

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kort
#7 2014-01-24 11:39

If you need a global for current category description, use

{PHP.cat.desc}

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#8 2014-01-24 15:44

That global does not exist. At least not for me when I check with : {PHP|dump}
My test website I am currently running is not updated to the latest SIENNA version though. Maybe its only added recently.

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kort
#9 2014-01-24 17:29

Did you check?

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#10 2014-01-24 21:39

Not yet Kort, I need to install 0.9.16 on a seperate area and see if with that version the PHP dump outputs the {PHP.cat.desc}.

I will let you know, I should be able to perform an additional install this weekend.
Thanks for all your help so far, also to Twiebie, I really appreciate it!
 

Added 2 days later:

I just installed 0.9.16 and there does not exist a global called "{PHP.cat.desc}".
I will have to try to make my nav menu's in the list only showing it when count == 1 I guess.

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
This post was edited by foxhound (2014-01-26 15:33, 10 years ago)
Kort
#11 2014-01-26 17:13

Did you TRY to use it?

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#12 2014-01-27 16:49

Yes, of course I tried it to see the output. I guess I should have told you the results of that, I forgot sorry.

index.tpl --> {PHP.cat.desc} --> no output
news.tpl --> {PHP.cat.desc} --> no output (at least not outside of the ROW)
page.tpl --> {PHP.cat.desc} --> outputs the page category

Sadly, I would like it to work on the index / news.tpl (but outside of the row).
 

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kort
#13 2014-01-28 06:49

Which template did you use it in?

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#14 2014-01-30 20:48

Tested in the default template nemesis but also in my own. And the result is always the same (see post #12).

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />