joomla3.0joomla-k2

Detect on template index file if Joomla K2 item or Joomla Article


I am looking for help on how to do a detect if "page" is coming from a K2 item or Joomla article in my index file.

Example:

If "page" is k2 item show this content else if is Joomla article show this content.

The reason I need to do this is I need to have a different grid structure for general pages vs what is k2.


Solution

  • Joomla content fully controlled by database. Each page url has atleast one common input: option. Your fact is identify 2 content source: core article(com_content) and k2(com_k2). So just pick the url variable option's value and check.

    $input = JFactory::getApplication()->input;
    $option = $input->get('option');
    
    if($option == 'com_content') {
        // Show content for Joomla article
    } else if($option == 'com_k2') {
        // Show content for k2
    }