Use categoryid=$variable in {phocagallery view=category}

Phoca Gallery - image gallery extension
namford
Phoca Member
Phoca Member
Posts: 22
Joined: 25 Jun 2015, 18:11

Use categoryid=$variable in {phocagallery view=category}

Post 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 :-)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49144
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Use categoryid=$variable in {phocagallery view=category}

Post 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
If you find Phoca extensions useful, please support the project
namford
Phoca Member
Phoca Member
Posts: 22
Joined: 25 Jun 2015, 18:11

Re: Use categoryid=$variable in {phocagallery view=category}

Post 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 :-(
namford
Phoca Member
Phoca Member
Posts: 22
Joined: 25 Jun 2015, 18:11

Re: Use categoryid=$variable in {phocagallery view=category}

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49144
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Use categoryid=$variable in {phocagallery view=category}

Post 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
If you find Phoca extensions useful, please support the project
namford
Phoca Member
Phoca Member
Posts: 22
Joined: 25 Jun 2015, 18:11

Re: Use categoryid=$variable in {phocagallery view=category}

Post by namford »

Sorry, I do not understand. Where *should* I put the code to make this possible? Thank you.
namford
Phoca Member
Phoca Member
Posts: 22
Joined: 25 Jun 2015, 18:11

Re: Use categoryid=$variable in {phocagallery view=category}

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49144
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Use categoryid=$variable in {phocagallery view=category}

Post 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
If you find Phoca extensions useful, please support the project
namford
Phoca Member
Phoca Member
Posts: 22
Joined: 25 Jun 2015, 18:11

Re: Use categoryid=$variable in {phocagallery view=category}

Post by namford »

Hi, it seems my last post on this topic has - again - not been published, please could you authorise it? Thank you
User avatar
Benno
Phoca Hero
Phoca Hero
Posts: 9965
Joined: 04 Dec 2008, 11:58
Location: Germany
Contact:

Re: Use categoryid=$variable in {phocagallery view=category}

Post by Benno »

please could you authorise it? Thank you
Done!

Kind regards,
Benno
Post Reply