Ajax and Ajax Frameworks

I have been a developer for nearly 20 years and a web developer for about 10 years. Over the years, I have considered creating a blog to share the things I have learned (and am learning) about web design and development, but I never seemed to have the time. When I began learning about web development using Ajax and Ajax Frameworks, I decided to take the time to create this blog.

My intention for this blog is to focus primarily on Ajax Frameworks, but since web development requires knowledge of many technologies, I will occasionally write about things such as CSS, Javascript, PHP, MySQL, Flash, etc.

Lately, I have been using JQuery as my primary Ajax tool. Although I have used other Ajax Frameworks in the past (Dojo Toolkit, Yahoo! User Interface Library, Scriptaculous/Prototype), JQuery has thus far been the easiest to learn. In my first few posts I will discuss some of the JQuery Plugins that I have created. Some of these include: a plugin for Google Maps (jquery.imGoogleMaps), Form validation and submission  (jquery.imValidateForm), Page Populater (jquery.imPagePopulate), and a plugin to create lists (jquery.imList).

While I am still learning about some of the other Ajax Frameworks, I hope that what I have learned will be helpful to others. Just remember, “When you can pull the pebbles from my hand…”

Share

Creating a Multi-View Joomla Template

Friday, May 21st, 2010

I have nearly completed my new portfolio site. I built it using Flash and Joomla. I created a Flash application to display the actual portfolio (thumbnails, links, etc). I then created a Joomla component and module (gsPortfolio) that incorporates the Flash portfolio application.

When I created the Joomla template for my site, I designed it specifically for the display my portfolio. Unfortunately, this layout was not generic enough to accommodate secondary pages (my portfolio is displayed on the home page). After looking at the code of the JA_Purity template, I was able to figure out how to create multiple views in a single template.

Note: Although with Joomla, you can select a different template for any page, my goal was to have different layouts incorporated into the same template – A layout for the front page and a layout for the secondary pages.

The Views

First I created a folder under my template folder named views (templates/myportfolio/views). I create two files under the views folder (frontpage.php and main.php). I created the frontpage.php file by copying everything that was in the index.php file (remember, my portfolio is contained on my home page). The main.php file contains the layout for all other pages for my site.

The Index.php File

I then changed the index.php file into a controller. I actually created a php class, but I will simplify the code for the purposes of this post.

<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
 
<?php 
function isFrontPage(){
	return (JRequest::getCmd( 'view' ) == 'frontpage') ;
}
 
if (isFrontPage()) {
	include_once (dirname(__FILE__).DS.'/views/frontpage.php');
} else {
	include_once (dirname(__FILE__).DS.'/views/main.php');
}
?>

I borrowed the isFrontPage function from the JA_Purity template. If the page displayed is the home page, then include the file /views/frontpage.php, else include the file /views/main.php.

The CSS Files

I created three css files. A file that is shared by all pages and styles that are specific by to each page. I include these files within each view. For instance, in the frontpage.php file:

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template?>/css/styles_all.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template?>/css/styles_front.css" type="text/css" />

That’s it. Fairly simple. Now I have multiple views in one Joomla template. Enjoy.

Share

CommentLuv badge