Page 1 of 1
Use categoryid=$variable in {phocagallery view=category}
Posted: 28 Jun 2015, 21:36
by namford
Hello
I have a phocagallery inside a Joomla article, but I want to get the categoryid from the article url using post/get. I already know how to post the value in url, but how can I put the get value inside the { } code?
E.g. I would like to do this:
$uri = JUri::getInstance();
$cat_id = $uri->getVar('catid');
{phocagallery view=category|categoryid=
$cat_id|limitstart=0|limitcount=3}
I already tried these two options, but neither work:
1) echo '{phocagallery view=category|categoryid=' . $cat_id. '|limitstart=0|limitcount=3}; -- this just displays the code as plain text in the article
2) {phocagallery view=category|categoryid=$cat_id|limitstart=0|limitcount=3} -- this causes the article not to display at all
Please advise how I can do this, thank you

Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 29 Jun 2015, 12:47
by Jan
Hi, the problem is, if you are in article, you get the ID from article, not from the plugin which is inside the article.
So you cannot get it per GET as in GET id of article is.
And you cannot get it per POST as POST is going through form which is sent and there is no form
If you want to get some ID and work with it, you need to do directly in the plugin code, but:
$cat_id = $uri->getVar('catid');
this means, you will get article category id, not the Phoca Gallery category id and I think, there is no catid in articles, so in fact you will not get anything there.
If you are inside the article like the plugin is, you cannot get GET value from another component - you get ID of article so not sure which value you want to get.
For example, you are in Article ID 35 and you ask for category from Phoca Gallery, but from which category?
Jan
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 29 Jun 2015, 20:48
by namford
Sorry, I should have given example of URL to make this clear.
URL of article is:
http://sitename.com/index.php/article1?cat_id=5
So when I do $cat_id = $uri->getVar('catid'); I get $cat_id = 5
If I do this:
$uri = JUri::getInstance();
$cat_id = $uri->getVar('cat_id');
echo '{phocagallery view=category|categoryid=' . $cat_id. '|limitstart=0|limitcount=3};
Displayed as text in article is the correct syntax and category number, but it is TEXT not executed code. It shows as:
{phocagallery view=category|categoryid=5|limitstart=0|limitcount=3}
but this is text not code

Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 05 Jul 2015, 23:00
by namford
I noticed a typo in my previous reply, so I corrected it, but now its gone for approval again

Sorry, please can you approve it. Thank you.
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 06 Jul 2015, 00:00
by Jan
Hi, where you paste this code:
a) if the code is pasted to editor, then the php is not transformed and the plugin is not recognized
b) if the code is pasted to php code, then the plugin code get right form, because php code is executed but the whole plugin code cannot be transformed as plugin codes are transformed only when they are inside content (text stored in database)
Jan
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 06 Jul 2015, 00:22
by namford
Sorry, I do not understand. Where *should* I put the code to make this possible? Thank you.
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 07 Jul 2015, 22:40
by namford
Don't worry! The amazing guys at AlterReports have made this work inside their report, so I no longer need it to work here - ALTHOUGH it would be really cool functionality to use variables inside the PhocaGallery code and I hope you can look into it. By the way...the AlterReports guys reordered the plugins so that the code that populates my variable (in this case AlterReports) is before PhocaGallery, so that when PG executes, the variable is already a number (the category id). Hopefully playing with the order when PG gets executed could be applied similarly to make this solution work elsewhere.
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 07 Jul 2015, 22:44
by Jan
Hi, in previous post, I have in fact written, that there are two possible ways I understand what you want to do. But both cannot be done in Joomla! (PHP, I think, maybe there is some way I don't know)
Joomla! needs specific string to recognize, this is a plugin, but you in fact break it with the variable, so Joomla! will not recognize this string:
it recognizes: {a=1}
but not:
$a = 1
echo '{a='.$a.'}';
Jan
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 15 Jul 2015, 13:14
by namford
Hi, it seems my last post on this topic has - again - not been published, please could you authorise it? Thank you
Re: Use categoryid=$variable in {phocagallery view=category}
Posted: 16 Jul 2015, 14:50
by Benno
please could you authorise it? Thank you
Done!
Kind regards,
Benno