user2606353
user2606353

Reputation: 79

Joomla get content by ajax

How to get joomla content using ajax? (I want to show content of specyfic page in popup), this is my code: (called by ajax)

$option = JRequest::getCmd('option');
    $view = JRequest::getCmd('view');
    if ($option=="com_content" && $view=="article") {
      $ids = explode(':',JRequest::getString('id'));
      $article_id = $ids[0];
      $article =& JTable::getInstance("content");
      $article->load($article_id);
      echo '<h2>'.$article->get("title").'</h2>';
      echo $article->get("introtext"); // and/or fulltext
    }

This works fine only for artilces, but the problem is when for example I want to show category, or component

Upvotes: 0

Views: 589

Answers (1)

atpatil11
atpatil11

Reputation: 433

Please see your if condition it checks if option is equal to com_content & view is equal to article only. If view contains category it won't work. So add the conditions in if statement so that your code gets executed. for category you need to add view=category & like for other components as well.

Upvotes: 1

Related Questions