Search
Other Articles Anywhere questions
Forum

Show different articles for different user group - on homepage

Bernhard Woehrlin's Avatar Bernhard Woehrlin
Hi,

I am wondering if it is possible to show two different articles for different users groups - logged in and non-logged-in users. Therefore I added a code on a test article:
{source}
<?php
if($user->get('guest')) {
   {article id="480"}
   [introtext]
   {/article}
} else {
   echo 'Welcome ' . $user->name . ', you are now logged in!';
}
?>
{/source}
But I get an error. - Is this possible anyways? What am I missing?
Thanks for any hint.
Kind regards,
Bernhard
Peter van Westen's Avatar Peter van Westen ADMIN
Your Articles Anywhere tags are not php code. So output it as a string:
{source}<?php
echo $user->get('guest')
   ? '{article id="480"}[introtext]{/article}';
   : 'Welcome ' . $user->name . ', you are now logged in!';
?>{/source}

You could also use Conditional Content for this, instead of doing this via PHP/Sourcerer.
Please post a rating at the Joomla! Extensions Directory
Bernhard Woehrlin's Avatar Bernhard Woehrlin
Peter, you are my hero!
Peter van Westen's Avatar Peter van Westen ADMIN
😉 😁
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription