I'm managing a Joomla website that uses DJ Classifieds as the main component; the 'ads' are actually resumes, and employers buy a subscription to access an ad's details.
In the past, users who didn't have a subscription were redirected to a sign up blurb (an article) when they clicked on the listing's title; users who did have an active subscription were taken to the ad's details page. This process was handled by OS Membership, which added users to an 'authorised' user group upon purchasing a subscription, and in DJ Classifieds, I set access to ad details to that same user group. It all worked perfectly.
The problem was, though, that the browser was creating 301 redirects; any user who clicked on an ad BEFORE buying a subscription was redirected to the sign up blurb but, then even after they bought a subscription, the browser continued to redirect them, since a 301 had been created. (that's my layman's understanding of it)
The component's developer fixed this by adding a 'no-cache' 'must re-validate' line of code and the problem was solved. However, it also meant I couldn't cache anything and now the site is slow.
And so, I had a better idea but I can't quite make it work.
I'm trying to add some code that does the following:
if the user belongs to 'authorised' group {
show ad title with link to ad detail
} else {
show ad title with link to sign up page
}
It sounds easy, but the hard part is knowing how to use apostrophes and quotations; the code from the PHP file is below and it already contains PHP snippets, so my question is, how can I write this to make it work?
=== my idea ===
At top of the php file:
$user = JFactory::getUser();
In the page itself:
<th style="" class="name first <?php echo $class; ?>">
<?php } ?>
$group_id = 3;
if(in_array($group_id, $user->getAuthorisedGroups()))
{
//when the user is in the authorised group
echo '<a <?php echo $title_a_style;?> class="<?php echo $class; ?>" href="index.php?option=com_djclassifieds2&view=items&cid=<?php echo $main_id; ?>&order=title&ord_t=<?php echo $ord_t.'&Itemid='.$Itemid;?><?php echo $se_link;if($uid){ echo '&uid='.$uid; }?>">
<?php echo JText::_('COM_DJCLASSIFIEDS2_TITLE');
if($order=="title"){
if($ord_t=='asc'){
echo '<img src="'.JURI::base().'/components/com_djclassifieds2/assets/images/sort_desc.gif" alt="" />';
}else{
echo '<img src="'.JURI::base().'/components/com_djclassifieds2/assets/images/sort_asc.gif" alt="" />';
}
}else{
echo '<img src="'.JURI::base().'/components/com_djclassifieds2/assets/images/sort.gif" alt="" />';
}
?>
</a>;'
}else{
echo '<a <?php echo $title_a_style;?> class="<?php echo $class; ?>" href="/link-to-signup-article">
<?php echo JText::_('COM_DJCLASSIFIEDS2_TITLE');
if($order=="title"){
if($ord_t=='asc'){
echo '<img src="'.JURI::base().'/components/com_djclassifieds2/assets/images/sort_desc.gif" alt="" />';
}else{
echo '<img src="'.JURI::base().'/components/com_djclassifieds2/assets/images/sort_asc.gif" alt="" />';
}
}else{
echo '<img src="'.JURI::base().'/components/com_djclassifieds2/assets/images/sort.gif" alt="" />';
}
?>
</a>;'
?>
</th>
I feel embarrassed knowing so little about the above, and I've tried all different permutations but I don't know how to use apostrophes and quotations within the query itself.
Can anyone help me make this work?