To get article title and text using id in joomla

<?php

$article_id = $id';
$article =& JTable::getInstance("content");
$article->load($article_id);
echo '<h1>'. $article->get("title").'</h1>';
echo $article->get("introtext"); // and/or fulltext

?>
Advertisements

Error: Duplicate entry ‘1-‘ for key ‘whosonline’

Backup your database then try doing a repair and optimize on your database and see if that helps. If you do not know how ask your Host to do it.

PhpMyAdmin Tutorial: Repair and Optimize Database

Sometimes the database tables get crashed. Also, they should be optimized from time to time. In this part of our PhpMyAdmin tutorial we will show how to repair and optimize database tables through PhpMyAdmin.

How to Repair MySQL Database Tables?

Open the database which should be repaired.

Select the tables that need repair and pick the Repair table action from the drop-down menu located below the tables’ list.

The tables will be repaired and you will get a confirmation screen.

How to Optimize MySQL Database Tables?

Open the database which you want to optimize.

Select the tables that need optimization.

From the drop-down menu pick the Optimize table option.

After the tables’ optimization a confirmation message with a list of the optimized tables will be visualized on the screen.

joomla form validation in controller

// GET THE DATA FROM THE POSTED FORM
$data = JRequest::getVar(‘jform’, array(), ‘post’, ‘array’);
// USE THE MODEL CLASS TO LOAD THE FORM OBJECT.
$form = $this->getForm($data);
// GET THE VALUE OF A SPECIFIC FIELD
$a = $form->getValue(‘a’);
// IF THE VALUE OF a IS ZERO, THEN b IS NOT REQUIRED
if((int)$a == 0){
$form->setFieldAttribute(‘b’, ‘required’, ‘false’);
}
// VALIDATE THE FORM BASED ON CHANGES YOU MADE
$form->validate($data);