Let us Study, Learn and Understand the Joomla Code Together

Pag usapan ang mga bagay na ukol sa pangkalahatang interes sa web at Joomla!
User avatar
guilliam
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4181
Joined: Thu Aug 18, 2005 10:27 am
Location: Sunny City Cebu, Philippines!
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by guilliam » Fri Jun 02, 2006 12:48 pm

@deathwingpnx,

you may check on the footer of the api docs:
"Documentation generated on Sat, 4 Feb 2006 14:23:37 +0100 by phpDocumentor 1.3.0RC4"
as far as i can remember the dev docs are more geared towards the 1.5 now.
IMO, i dont htink much of updates on the dev doc of 1.0.x series would be updated for this reason. ;)

- g
Last edited by guilliam on Fri Jun 02, 2006 12:50 pm, edited 1 time in total.
"I was one of those who wondered why people would pay so much $$$$ to do something that was so much fun!" -R. Harkrider, Fortran Code Engr.

http://www.joomlaconsultancy.net

 
User avatar
freakismarco
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 232
Joined: Tue May 02, 2006 9:24 am
Location: Davao City, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by freakismarco » Wed Jun 07, 2006 2:14 am

For newbies, gaya ko
Study muna tayo ng PHP basics.
advance yung classes ng Joomla.

User avatar
padz0407
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Fri May 12, 2006 6:58 am

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by padz0407 » Wed Jun 07, 2006 3:56 am

nice thread here.. but for us beginners in PHP.. it is quite hard to understand some of the codes...
i find some difficulty in understanding object-oriented coding structure....

but i appreciated the effort of sharing your knowloedge with us... thanks a lot for that...
more power to you... specially sa mga bisaya....

daghang gahom (more power) hehehehe.....

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed Jun 07, 2006 9:09 am

Creating a Press Release Component for Eric Banug.

Eric wants a press Release Component for his site and wants to learn component making in the process.  So do I.  That is why with your help, we will create a component for him.

Medyo Original na to hindi na kinostomized. ;)

First we will create a very basic component in order for us newbies not to be confused with component making.

Installation and Uninstallation files.
gmaebpress.xml
install.gmaebpress.php
uninstall.gmaebpress.php

Admin Component File
admin.gmaebpress.php

Frontend Component File
gmaebress.php

Now, we will start with only 5 files (I made this as few as possible for us begginers better understand it).

Basically the only functionality of this right now is to display a members press release when selected in the frontend of your website and some display in the backend or administration part.  More will be added slowly as we progress with the tutorial.

Press Release Component Tutorial 1 download
http://glennapolinario.homelinux.com/in ... &Itemid=81
Last edited by deathwingpnx on Thu Jun 08, 2006 6:39 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed Jun 07, 2006 9:31 am

gmaebpress.xml

This is the most important file in the installation because this file contains the component installation instructions.

gmaebpress
This line is very important because the entry here is the subdirectory created at administrator/components and /components.  com+name = com_gmaebpress is your component direcotry.

Code: Select all

  <files>
    <filename>gmaebpress.php</filename>
  </files>
This file is copied to the frontend component directory.  Just one file for now for us not be confused.

Code: Select all

    <queries>
      <query>DROP TABLE IF EXISTS `#__gmaebpress`</query>
      <query>
        CREATE TABLE `#__gmaebpress` (
          `id` int(10) NOT NULL auto_increment,
          `uid` int(10) NOT NULL default 0,
          `vote` int(10) default NULL,
          `subject` char(35) NOT NULL,
          `text` text NOT NULL,
          `text_more` text,
          `date_entered` datetime default NULL,
          `comment` text,
          `edit` enum('y','n') NOT NULL default 'n',
          `date_lastedit` datetime default NULL,
          `published` tinyint(1) NOT NULL default '0',
          PRIMARY KEY  (`id`)
        ) TYPE=MyISAM
      </query>
      <query>
	  	INSERT INTO #__gmaebpress
	  		(uid, subject, text, text_more, date_entered, date_lastedit, published)
	  		VALUES
	  		(0, 'Sample Press Release', 'Ito ay isang sample Press Release na nagsasabing pogi si Eric Banug', 'Pero mas pogi si Glenn Miranda Apolinario', '2006-06-07 01:01:01', '2006-06-07 01:01:01', 1)
      </query>
    </queries>
These are queries executed upon installation.  In this instance,
1.  I drop the table jos_gmaebpress if it exists.
2.  Created a table for our press release data to be stored.
3.  Inserted a sample press release post to our table.

Code: Select all

  <uninstall>
      <queries>
      <query>DELETE FROM `#__gmaebpress`</query>
      <query>DROP TABLE `#__gmaebpress`</query>
      </queries>
  </uninstall>
    <installfile>install.gmaebpress.php</installfile>
    <uninstallfile>uninstall.gmaebpress.php</uninstallfile>
Here are uninstallation sql queries and declaration of installation and uninstallation files.
Actually the contents of these files will be executed or displayed when installing or uninstalling our
our component.  You can cleary see which is which.

Code: Select all

  <administration>
    <menu>GMA Press Release</menu>
    <submenu>
      <menu task="view">Tingnan</menu>
      <menu task="config">Baguhin ang Configurasyon</menu>
      <menu task="language">Baguhin ang Wika</menu>
      <menu task="about">Tungkol sa GMAEB Press Release</menu>
    </submenu>
    <files>
      <filename>admin.gmaebpress.php</filename>
      <filename>install.gmaebpress.php</filename>
      <filename>uninstall.gmaebpress.php</filename>
    </files>
</administration>
This is the fun part.  It is here where we declare the admin menu entries.  The installer will save this to the
component table and automatically make some configurations to the admin menu.  Files are also copied to the
administrator/components directory which are admin.gmaebpress.php, install.gmaebpress.php and unistall.gmaebpress.php
Last edited by deathwingpnx on Wed Jun 07, 2006 10:21 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed Jun 07, 2006 10:23 am

administrator/com_components/gmaebpress/install.gmaebpress.php

Code: Select all

function com_install() {
  ?>
  <center>
  <table width="100%" border="0">
    <tr>
      <td>
        <strong>GMA EB Press Release .01 - A Joomla Press Release Component</strong><br/>
        <font class="small">© Copyright 2006 by Glenn Miranda Apolinario<br/>
        <font class="small">© Copyright 2006 for Eric Banug<br/>
        Released under the terms and conditions of the GNU General Public License.</font><br/>
      </td>
    </tr>
    <tr>
      <td background="E0E0E0" style="border:1px solid #999;" colspan="2">
        <code>Installation Process:<br />
        <font color="green"><b>Tapos na mag install.</b></font></code>
      </td>
    </tr>
  </table>
  </center>
  <?php
}
Display some information after installation proccess.  We can also add some sql queries and other commands
here.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed Jun 07, 2006 10:23 am

administrator/components/com_gmaebpress/uninstall.gmaebpress.php

Code: Select all

function com_uninstall() {
  echo "Component successfully uninstalled.";
}
Display some information after uninstallation proccess.  We can also add some sql queries and other commands
here.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed Jun 07, 2006 10:24 am

administrator/components/com_gmaebpress/admin.gmaebpress.php

Code: Select all

switch ($task) {
  	case "edit":
    	echo "babaguhin natin ang press release";
    	break;

  	case "config":
    	echo "ipapakita natin ang konfigurasyon ng press release press release";
    	break;

  	case "about":
    	echo "<p>sino ang mga pogi sa Press Release?";
    	echo "<p>Glenn Apolinario";
    	echo "<p>Eric Banug";
    	break;

  	case "language":
    	echo "ano ang wikang gamit ng press release";
    	break;

  	default:
    	echo "ipapakita natin ang list ng press release";

		echo "<table width='100%' border='0' cellspacing='1' cellpadding='4'>";
		echo "<tr>";
        	echo "<td width='20%' class='sectiontableheader'>SUBJECT</td>";
   	    	echo "<td width='40%' class='sectiontableheader'>PRESS RELEASE</td>";
       		echo "<td width='40%' class='sectiontableheader'>MORE</td>";
		echo "</tr>";

		$database->setQuery( "SELECT * FROM #__gmaebpress"
			. "\nWHERE published = 1"
			. "\nORDER BY date_entered"
		);

		$rows = $database->loadObjectList();
		foreach ( $rows AS $row) {
			echo "<tr>";
				echo "<td>$row->subject</td>";
			  	echo "<td>$row->text</td>";
			  	echo "<td>$row->text_more</td>";
          	echo "</tr>";
		}
		echo "</table>";
    	break;
}
echo "<p> </p>";
echo "<p><font class='small'>© Copyright 2006 by <a href='http://glennapolinario.homelinux.com' target='_blank'>Glenn Miranda Apolinario</a><br />Version: .01</font></p>";
echo "<p><font class='small'>© Copyright 2006 for <a href='http://http://ericbangug.com' target='_blank'>Eric Banug</a><br />Version: .01</font></p>";
This is the file which controls program flow in the administrator backend for our component.  I have made
some output to replace certain task and the only functioning part here is the display of the press release
entries made by our members.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed Jun 07, 2006 10:24 am

components/com_gmaebpress/gmaebpress.php

Code: Select all

function pressHeader() {
	echo "<table width='100%' border='0' cellspacing='1' cellpadding='4'>";
	echo "<tr><td class='sectiontableheader'>GLENN ERIC PRESS RELEASE</td></tr>";
	echo "</table>";
}

function pressFooter() {
   	echo "<center><span class='small'>Powered by <a href='http://glennapolinario.homelinux.com/' target='_blank'>Glenn</b></a> for <a href='http://ericbangug.com'>Eric</a> Press Release</a> </span></center>";
}

pressHeader();

switch ($func) {
	default:

        $database->setQuery( "SELECT id, name FROM #__users "
    	    . "\nORDER BY name"
        );
        $rows    = $database->loadObjectList();
        $members = array();
		$members[] = mosHTML::makeOption( 0, 'Guest');
		foreach ($rows as $val) {
			$members[] = mosHTML::makeOption( $val->id, $val->name);
		}
		$damember = mosGetParam( $_REQUEST, 'member');
		echo "<form name='myform' method='post'>";
		echo mosHTML::selectList( $members, 'member', "class='inputbox' size='1' onchange='document.myform.submit();'", 'value', 'text', $damember);
		echo "</form>";

		echo "<table width='100%' border='0' cellspacing='1' cellpadding='4'>";
		echo "<tr>";
	        echo "<td width='20%' class='sectiontableheader'>SUBJECT</td>";
    	    echo "<td width='40%' class='sectiontableheader'>PRESS RELEASE</td>";
        	echo "<td width='40%' class='sectiontableheader'>MORE</td>";
		echo "</tr>";

		$dawhere = ($damember) ? " AND id = $damember " : "";
        $database->setQuery( "SELECT * FROM #__gmaebpress"
	        . "\nWHERE published = 1"
		 	. "\n $dawhere "
    	    . "\nORDER BY date_entered"
        );
        $rows = $database->loadObjectList();
        foreach ( $rows AS $row) {
          echo "<tr>";
		  	echo "<td>$row->subject</td>";
		  	echo "<td>$row->text</td>";
		  	echo "<td>$row->text_more</td>";
          echo "</tr>";
        }
        echo "</table>";

        break;
}

pressFooter();
This is the file which controls program flow in the user front endfor our component.  I have only displayed
here the press releases of members based on what is selected at the list box.  First I displayed the header,
then the main body depending on the task required but only one for now and lastly the I displayed the footer.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
freakismarco
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 232
Joined: Tue May 02, 2006 9:24 am
Location: Davao City, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by freakismarco » Thu Jun 08, 2006 3:46 am

galing mo nman tol.. at napakabait pa

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Thu Jun 08, 2006 5:18 am

freakismarco wrote: galing mo nman tol.. at napakabait pa
Not really, Im still studying Joomla and have a lot to learn pa.  The more I learn, the more I discover that I still know little.  Ikaw nga ang magaling cause youll all over the place.  Helping in the administration, general discussions, troubleshooting in some zones such as dutch, katalan, bosnian, bosque and I see you also know arabic.  You know a lot about Joomla based on the posts youve made and almost all of them are in the international support forum.  Just yesterday you had more or less 10 post only for support.  Ikaw ha. ;)

Thanks and more power to all.
Last edited by deathwingpnx on Fri Jun 09, 2006 10:49 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
freakismarco
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 232
Joined: Tue May 02, 2006 9:24 am
Location: Davao City, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by freakismarco » Fri Jun 09, 2006 10:11 am

hehe.. puro "HELLO" lang yung mga posts ko doon

diba ang mga programmer una natutong "HELLO WORLD"

so nagHELLO ako sa WORLD.

hehehe

Doomla!

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by Doomla! » Mon Jun 12, 2006 7:16 am

pano po ba mag palit ng email add? sa performs n component?

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Tue Jun 13, 2006 4:16 am

Upon editing the Form, there is a tab in the right area named E-Mails.  Place the email addresses there seperated by commas.  Also upon creating a form you can create email fields.  I hope this helps you.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

ericb
Joomla! Guru
Joomla! Guru
Posts: 736
Joined: Sat Feb 25, 2006 4:44 pm
Location: Metro Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by ericb » Mon Jun 19, 2006 1:46 am

boss deathwing check mo pm mo... may prob ako sa php pattemplate. salamat :)
www.phpugph.com - PHP Users Group Philippines

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon Jun 19, 2006 4:01 am

Tito Eric,

Hindi ko pa na try ang pattemplate kasi gamit ko htmltemplateit doon sa app ko, check ko baka mas maganda sya un na gamitin ko. Wow Galing mo na, nasa object oriented programming kana. Hehehe! :laugh:  I seldom use templating because my apps are mostly database driven applications, and in when using templating and extracting large amounts of data, it tends to be slower than not using templating. One instance of this is when I tried to use templating in displaying all the barangays in the Philippines which in our tables has
43,521 records, was finished in 55 seconds.  When not using templating, it managed to be displayed in only 20 seconds.
Last edited by deathwingpnx on Mon Jun 19, 2006 10:33 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon Jun 19, 2006 8:44 am

You can also display the details of the position by just adding a varible which is the same in the table for position details.
{POS_DSC} {POS_DET}

Well actually the idea is simple and easy.  If I am correct, you are saying is display position description in a page, and when clicked opens another page with the details.  The hard part here is I am not familiar with built in functions of pattemplate and the code you gave was too short.  Anyway Ill try to give it a shot.

Code: Select all

<a href="javascript:openwin('{POS_ID}');">{POS_DSC}</a>
This is the link that displays a pop up window for the position details.  POS_ID is an assumption, this is the key field which we will pass to the next page.  This is the value which will determinte the the position details to be displayed on the next page prior to the database query.

Code: Select all

/*
			$position = array (
               			array( 'POS_ID' => '1', 'POS_DSC' => 'Manager' ),
                   		array( 'POS_ID' => '2', 'POS_DSC' => 'Supervisor' ),
                  		array( 'POS_ID' => '3', 'POS_DSC' => 'Rank and File' ),
			);
*/
$position   =   $this->getHelpPosition( $where );
$this->template->addRows("otherhelp_dtl_helptopics_positionlist", $position );
The first line is your own function which fetches the array value and assigned to position.  In the retrieval of data not just only POS_DSC but POS_ID (assumed primary key) must also be retreived.

Code: Select all

<SCRIPT LANGUAGE="javascript">
function openwin(posid) {
    open('positiondet.php?posid='+posid, 'positiondet');
}
</SCRIPT>
Create you popup opener between the tags.

Now, this should be fine with the existing script.  The second Page should be easy cause you only need to retrieve the position details using the passed value which is your primary key relating to the position you chose.

After using your own userdefined function for fetching the position details you can just add this to your php script

Code: Select all

$tmpl->addVar("my_postion_details", "POS_DET", $row['pos_det']); 
Then insert this to your template

Code: Select all

<pattemplate:tmpl name="my_postion_details">
{POS_DET}
</pattemplate:tmpl>
Last edited by deathwingpnx on Mon Jun 19, 2006 9:55 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

ericb
Joomla! Guru
Joomla! Guru
Posts: 736
Joined: Sat Feb 25, 2006 4:44 pm
Location: Metro Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by ericb » Mon Jun 19, 2006 10:50 am

do you want me to send the two files?? the tmpl file and the php file bro??? still i am having a hard time with that code...

and whenever i try to change a single code...and undo it so that the original code will be back again... i am getting errors... :(
www.phpugph.com - PHP Users Group Philippines

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon Jun 19, 2006 10:55 am

Back up the original code.
ericb wrote: do you want me to send the two files?? the tmpl file and the php file bro??? still i am having a hard time with that code...

and whenever i try to change a single code...and undo it so that the original code will be back again... i am getting errors... :(
If posible yes, and the table structure.  Try to run it here and add the changes.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

ericb
Joomla! Guru
Joomla! Guru
Posts: 736
Joined: Sat Feb 25, 2006 4:44 pm
Location: Metro Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by ericb » Tue Jun 20, 2006 7:06 am

i'll try to work on it nalang muna lam ko busy din kayo sa kanya kanyang trabaho.... :) salamat sa effort ha. pag ndi ko na kaya saka ako ulit hingi ng tulong. salamat
www.phpugph.com - PHP Users Group Philippines

 

Locked

Return to “Pinoy General Discussion & Archives”