Today I wanted to show you how easy it is to add a content editor in your Joomla component form.
First we want to have the array of States in our code. See Below.
$states = array("AK","AL","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID",
"IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH",
"NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA",
"WI","WV","WY");
Then you want to create the list (select list options). Above is the simplest way of creating a state array, but right now the key of each array is 0, 1, 2. This is not what we want, we want the key and value of the array to be the same. So this next line fixes just that.
Below is how you set the page title for a Joomla 1.5 component.
With MVC, the standard place to put this code is going to be the view.html.php file inside your view folder.
$document = JFactory::getDocument();
$document->setTitle('Title of Page');
And that is it. Leave the comments below, hope this helped!
This is a way to insert data into a Joomla Database. I use this mostly whenever I am using an Ajax call to a function that needs to be added quickly and neatly. This is what I use inside of that function.
$data = new stdClass();
$data->item = $post['item'];
$data->published = 1;
$db->insertObject('#__MYTABLE', $data, id);
Remember the key field of the database table. Mine being id, is included in the insertObject() function. Remember it is not supposed to be in the listing, it is supposed to be inside the function. This will need to be a specific variable value IF you do not have AUTO INCREMENT set for this field in the database.
Today I want to show you how easy it is to set a redirect in your Joomla Component. Below is the easiest way to go about this.
$app = JFactory::getApplication();
$app->redirect($link, $msg);
You will want to make sure that there are variables set for $link and $msg. Also this is best used with an IF statement. Here is a full example on how to use the redirect.
if($user->guest):
$link = 'index.php';
$msg = 'You are not logged in.';
$app = JFactory::getApplication();
$app->redirect($link, $msg);
endif;