I have a custom component, it allows admins to select a related content article from the #__content table using the following:
<field name="relatedcontent" type="sql" default="10" label="Related item"
sql_select="e.*"
sql_from="#__content AS e"
sql_group="title"
sql_order="e.title ASC"
key_field="id"
value_field="title"
header="Please select your option"/>
This then allows me to show in the frontend as follows:
$id_one = $this->item->interested_in_one;
<a href="<?php echo JRoute::_('index.php?option=com_content&view=article&id=' . $id_one); ?>">
This gets the ID of the selected content article and creates the URL accordingly from above.
I need to further extend this by:
- getting the alias (of the content article) in the URL
- stop Joomla from adding '&Itemid=101' to the end of the URL, or at least load the correct one