blog.calebnance.com

It's So Loud, Inside My Head...

Sunday, 15 January 2012 19:08

My E-commerce for Joomla 1.5?

I have been toying around with an E-commerce Component for Joomla for a while now. I have used Virtuemart for one site, and that is the last time I will be using that component. It is too bulky, yes it is free, and comes with a huge options library, but what about the smaller stores? Do you honestly think that a regular user could use Virtuemart with ease? I want to put something out there (Commercial or free, undecided) that will be easy to use and straight to the point. That is what I try to do with all the extensions I have made so far. I think that is where everything is going, I want to help someone that is a regular user on the internet to be able to download my component, and have a store set up within 30 minutes. I have a lot of code for the E-commerce already created, but what about Joomla 1.7 and 2.5? I honestly think people jumped the gun with creating live websites with Joomla 1.7. It is great, but no where near the stable version Joomla 1.5.25. I still think it will be a good year before 2.5 is where Joomla 1.5.25 is.

Published in Components

Today I wanted to show you how easy it is to add a content editor in your Joomla component form.

Published in Code

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.

Published in Code
Wednesday, 19 October 2011 14:10

How To Set The Page Title In A Joomla Component

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!

Published in Code

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.

Published in Code

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;
Published in Code

Wanted to show you how easy it is to use the DISTINCT function in MySQL inside of Joomla.

This is very useful whenever you want to create a list of all the individual values of a specific field in a database table. It only gets that value once, so like below, there is several "Burlington" values in the city field

Table: jos_locations

id name city state
1 Coffee House Graham NC
2 Barnes & Nobile Burlington NC
3 Sheetz Mebane NC
4 Starbucks Burlington NC
5 Panera Burlington NC

So this is how you would use distinct to just grab that list of specific values.

// Get a database object
$db = &JFactory::getDBO();
$query = ' SELECT DISTINCT city '.
' FROM #__ locations ';

Now we want to Set the Query.

$db->setQuery($query);

Finally we send the query and return the Results and print it out.

$results = $db->loadObjectList();
print_r($results);

The results will be in an object oriented list like this:

Array ( [0] => stdClass Object ( [city] => Graham ) [1] => stdClass Object ( [city] => Burlington ) [2] => stdClass Object ( [city] => Mebane ) )

So let me know what you think, and hope this helped!

Published in MySQL

So you want to add a CSS or JS file to your component? Here is how you would do that, the easiest and best practice way.

Published in Code
Tuesday, 31 May 2011 23:15

Using Left Join In Joomla (MySQL)

Published in MySQL