Dynamic Site Design - Classnotes
Last Updated - 5/04/06
Week 2
To Archive Local Files
cd ~/sites tar -czvf [backup].tar.gz ./rdavidson
The "backup" file will be created, then when you open the file it will explore to create joffray.
In broswer : http:/localhost/~student/rdavidson
student$ cd~/Sites student$ cdchmod -R 777 rdavidson
To install:
- Download Joomla.tar.gz from network share/im255
- put it in ~/Sites/rdavidson
- Open terminal window -
tar -xzvf Joomla_1.0.8-Stable-Full_Package.tar.gz
To set file permissions
student$ cd ~/Sites student$ chmod -R 777 rdavidson chown -R www:www rdavidson
To create a database:
student$ cd /usr/local/mysql/bin ./mysql -u root mysql> create database rdavidson; show databases; exit;
Make sure to click 'Drop Existing Tables'
Host: hp3.ccom.net username: rdavidson password: *** database: rdavidson
Then return to the localhost and rename the installation folder to something else...refresh your browser and voila!
Move Database from internet(HP3) to Local, to get past the installer:
R106-08:/usr/local/mysql/bin student$ cd ~/Sites/rdavidson R106-08:~/Sites/rdavidson student$ ls Show what's in the folder 1.installation htaccess.txt CHANGELOG.php images COPYRIGHT.php includes INSTALL.php index.php Joomla_1.0.8-Stable-Full_Package index2.php Joomla_1.0.8-Stable-Full_Package.tar.gz language LICENSE.php mainbody.php administrator mambots cache media com_phpmyadmin262lite.zip modules components offline.php configuration.php offlinebar.php configuration.php-dist pathway.php editor rdavidson.sql globals.php robots.txt help templates R106-08:~/Sites/rdavidson student$ /usr/local/mysql/bin/mysql -u root rdavidson < ./rdavidson.sql
Week 3
- Homework - Create two spreadsheets in excell for each of your data sources.
- List City Officals - position and roles.
- Furnature - item list searchable
Once the spreadsheet is created then you export from excell as a CSV (comma seperate values) that's how you'll get this into mysql.
At least 6 records. *make sure you leave the first column open for the ID. This will be created by mysql.
To check if mysql is active type this in the terminal
R106-08:~ student$ /usr/local/mysql/bin/mysql rdavidson
When you activate your localhost mysql database you need to alter the configuration.php file in the local database folder.
configuration.php $mosConfig_offline = '0'; $mosConfig_host = 'localhost'; $mosConfig_user = 'root'; $mosConfig_password = '';

Here is a screenshot of the phpmyadmin control panel screen once you click on the export tab. These settings will export your database into a file which you can backup using the terminal.
Week 4
Checklist for beginning class
- Make sure your files are there
tar -xzvf rdavidson.tar.gz
- Make sure localhost is running
http://localhost/~student
- Make sure mysql is running
/usr/local/mysql/bin/mysql -u root rdavidson
- Check if your database is ready
mysql show databases;
To give write permission to the localhost
chmod -R 777 rdavidson
To change the owner of www
chown -R www:www rdavidson
To archive your database folder
tar -scvf rdavidson042706.tar.gz ./rdavidson
Week 5
Module vs Component
Module - is more periferal, (a search box, sidebar, latest entry, pull-down menu) Module does something with the data contained in a component. An extension of a component that gives useability.
Component - collection of data (database).
Talk about the names of the files and their uses. You need to know what each file is for before you use it. We need to follow the naming convention because the system has already been writen and we need to fit to it. It's important that these are named exactly. In
admin_schools_html.php or admin_schools.phpthe "schools" portion is what we change. The first is HTML, while the second is logic.
schools_class.phpstarts an object that extends the joomla class and is referable as far as the functions inside of it.
install_schools.hpsimply displays the message after install.
schools.phpis the public output...what is seen on the web. The public display of the data.
schools.xmlhas all of the install information. It will know based on the xml file where to put the schools.php file. It will also have the initial data and sql.
toolbar_schools_html.php and toolbar_schools.php
uninstall_school.phpdisplays a message when you uninstall.
- In JoomlaXplorer: rdavidson>administrator>components
- copy com_schools > rename to com_[your component name]
- go into copied component com_cityofficals
- change name of files to match your name
- go into public > components
- duplicate com_schools and rename
- copy up levels into the administrator components section into your component folder
- once you have them changed test by changing the URL to test your component
- Then go into the administrator component and edit to customize your own component.
How to convert the schools component into a component you can backwards engineer.
Homework - Create a web template in photoshop, Read Daily Message Tutorial (week4 Turtle Project)
Week 7
Add a published field to your component(database).
- Add A Published Field ->
- phpMyAdmin -> add published field -> add field at the end
published tinyint default 0
- export (not as a file) -> copy and paste the published line into your sql query in your component XML (installer config)
- also add var published to component class file
To Install a component
- Create your tables and fields in phpMyAdmin -> bottom of the main page Add your field names
- Make sure to set up a published field as shown above
- insert your data from your csv file
- Copy the files from the schools [component].php from the public folder into the admin component folder
- Rename all the files to match your component name ie [admin.furniture.html.php] etc.
- Export your database data and copy and paste it into your XML file (be sure to keep sql syntax using query and removing all semicolons.
- Be sure to keep the file names lowercase in the XML file since they are case sensative.
- Once you're done, rename your component folder com_[component]_org
- Then take the folder you just renamed and zip it up, make sure you don't have the download box clicked. Name the zip file 'com_[component]'.
- In Joomla, go to installers > components and point to your zip file. Click unzip&install. Then you troubleshoot :)
- Once you have it installed, edit your admin.[component].html.php to include all your data fields. That's in for the install.
id INT 11 NULL AutoIncriment [set as key]

This is a photo of what you copy after you export your database. Remeber to remove the ';' at then end and add a 'query' tag at the beginning and end.
Week 8
PHP FIX
The error with the php was caused by two problems. One was that the php version has changed which caused the second problem. In the new version of php a security feature was added
. This caused the global variables to no longer be availible by default. In order to access the global variables you need to pull them useing the REQUEST method built into mos. The code is:
$id = mosGetParam($_REQUEST, 'id', '');
You need to add this code on line 26 of your admin.mycomponent.php file. Once you do this you can access the $id variable and publish your component.
PUBLIC PHP FILE
- Go into your mycomponent.php file in the public folder using joomla explorer.
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
This code assures that this file is only accessed through joomla. - Next we declair $database as a global variable which is an object that joomla creates that we can access
- Then we have some sql query that will search through the database object that joomla
- $index%2? module 2 this checks if the variable $index is divisible by 2. meaning it's an even number.
$index%2?$newcolor='#333333':$newcolor='#666666';
index module 2 then the $newcolor for true : $newcolor for false
What will happen is as it runs through the loop it will alternate the background colors of the choices.
Week 9
How to edit a module within your template
- First you need to create your template. Within your design you take your module code and place the php code within a table or div depending on where you want it.
For example if you want your 'myModule' to show up in the middle of the page you would place the following code
mosLoadModules ( 'myModule' );
- Next, inside Joomla go to Site->Template Manager ->Module positions and declaired the positions with descriptions. This will help you identify modules you create specificly for your template.
- Go to Modules->Site Modules and create a new module.
- Under position -> Select the module you just declaired. Then save it.
- Then in the template html you put the above snipit (renamed of course). Then test your template.