Search
Other Sourcerer questions
Forum

Article ID

Radoslaw Kosinski's Avatar Radoslaw Kosinski
Hi,

Is it possible to get the article ID inside an article using sourcerer, so I can pass this value to a SQL query? I tried multiple options, but no luck. Any help is greatly appreciated.
Radoslaw Kosinski's Avatar Radoslaw Kosinski
I inserted echo $article->id; into the article as a test and it does not display any value.
Peter van Westen's Avatar Peter van Westen ADMIN
Try:
{source}<?php echo $article->id; ?>{/source}
Please post a rating at the Joomla! Extensions Directory
Radoslaw Kosinski's Avatar Radoslaw Kosinski
My apologies, very long day for me. Yes, I used the exact code that you specified.
Peter van Westen's Avatar Peter van Westen ADMIN
Are you placing this in a standard Joomla article?
Are you using a WYSIWYG editor?

What does this output?
{source}<?php echo '>' . $article->id . '<'; ?>{/source}
Please post a rating at the Joomla! Extensions Directory
Radoslaw Kosinski's Avatar Radoslaw Kosinski
Yes, a standard Joomla article with WYSIWYG editor (TinyMCE). We have other Joomla articles with PHP code working well using Sourcerer (db queries and so forth). The output of what you provided is:

><
Radoslaw Kosinski's Avatar Radoslaw Kosinski
Ok, so I found the issue. The article that I was displaying was not standard (overlooked it), but a custom page (using RocketTheme and Gantry 5 framework). Once I switched the menu item for the page to a single article, I got the article ID.

The URL for the single article is:

index.php?option=com_content&view=article&id=16

For the custom page:

index.php?option=com_gantry5&view=custom

Not sure if the URL makes a difference.
Peter van Westen's Avatar Peter van Westen ADMIN
The $article object refers to a stanard Joomla article.
Gantry does stuff differently.
If you want to get 'article' details from Gantry pages, you'll have to ask them for the php code to collect it.
Please post a rating at the Joomla! Extensions Directory
Radoslaw Kosinski's Avatar Radoslaw Kosinski
Thanks Peter for your responses!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription