Tuesday, October 6, 2009

Joomla

CMS name: Joomla 1.5 http://www.joomla.org/about-joomla.html



Download Url:http://www.joomla.org/download.html

CMS Type:  (CMS), The system includes features such as page caching to improve performance, RSS feeds, printable versions of pages, news flashes, blogs, polls, website searching, and language internationalization.


Installation
  1. http://help.joomla.org/content/category/15/99/132/
  2. http://docs.joomla.org/Joomla_installation
  3. 'JFolder::create: Could not create directory' .if this error is seen check 'Path to Temp-folder' in 'Global Configuration'.make sure the folder exists.
    Or
    It is indicated that some invalid paths setting found in the Joomla configuration file. You should try open up “configuration.php” and reset the paths for:
    1) $log_path
    2) $tmp_path
    Also check at Admin panel > Help > System Info > Directory Permission > make sure all listed given as Writable

Migration Steps:
  1. From 1.0 to 1.5 stable
Common Errors:
  1. 404 even if the pages are there as seen in admin:Reason-> either default item is not set in main menu OR the link item is unpublished OR SEF handling is incorrect.
Terminology :
  1. http://help.joomla.org/content/view/1607/214/
  2. http://www.dart-creations.com/joomla/joomla-tutorials/joomla-beginners-guide-to-joomla-terms.html


Tips: 
  1. To view inline positions use index.php?tp=1
  2. For additional security return ##configuration.php## to ##chmod 644## after making changes. Additional information on ##chmod## and permissions can be found at:
      * http://catcode.com/teachmod
      * http://www.evolt.org/article/A_quick_and_dirty_chmod_Tutorial/18/541/linux_The_chmod_command.html
  3. Protect files in download directory from direct downloading
  4. Legacy Plugin:
    Enabling the Legacy mode is not very straightforward. This is done by enabling a system plugin. To enable the plugin, you need to go to Extensions > Plugin Manager, find the plugin named System - Legacy, and click on the red cross to enable the legacy plugin.
    Once this has been enabled, any Joomla 1.0 template, component, module or mambot can be used on your Joomla 1.5 website. As we have already said, the legacy plugin does introduce additional overhead, and should be used with caution. If possible, always use Joomla 1.5 components and avoid using the Legacy plugin.
  5. To add captcha in contact us form the captcha plugin mentioned in this tutorial is not available for download so use this one

Security Issues:

Backup :Backip all files,backup db dump


Porting:

  1. create db
  2. import db dump
  3. edit configuration.php change $tmp_path,$log_path,$host ,$user ,$db ,$password(total 6)
  4. if 'System - Canonicalization' plugin is installed,change the 'host' parameter through MYSQL
    if   
  5. resetting user passwords
Good Reference URLS:
  1. http://docs.joomla.org/Beginners
  2. http://docs.joomla.org/Joomla!_1.5_Template_Tutorials_Project
Entity Relationship:http://www.torkiljohnsen.com/wp-content/uploads/2006/04/joomla_15_database_schema.png

General Details

  1. joomla 1.0 to 1.5 Migration guide , Migration guide 2  , Development Guide
  2. What are the main features ?
  3. Type of users: 1.0: http://help.joomla.org/content/view/476/153/ cant add more type in 1.0 (http://forum.joomla.org/viewtopic.php?f=267&t=59844)
  4. What can be done for each user?
  5. What features can be extended?What can be added? 

Admin :


  1. How to enable and disable offline mode:To put Joomla website offline, you must first login in the administration area. In the second step go to Site -> Global configuration.

    The first option that appears at this moment is Site Settings. On Site offline option, click the Yes button. Click the Save button at the upper right.

    To return online, follow the same steps, except at Site offline option, instead of Yes, you select No.

      Then click Save at the upper right.
  2. What all can be monitored? 
  3. How can a content be added
  4. How can menu items be controlled?
  5. How can template be changed?
  6. How SEO is enabled? tutorial Limits of basic SEO options(cant always convert links to meaning full urls) :    Artio ,(see more atio links in the bottom) sh404 :tutorial
  7.  , SEO tools 
  8. How meta tags are set? Can set in Global Configuration,for each article  using JoomSEO plugin  and and for each component with metadata class as in e2s component of insure-your-mobile
  9. How mass mail is done? Tools >> Mass mail
  10. Banner Management:
  11. News letter:ccNewsletter
  12. RSS: any article,category,section page can be viewd as RSS appending &format=feed.for example homepage can be viewd as RSS as index.php?format=feed
    Rss feed of items in a section or category page  eg:/index.php?option=com_content&view=category&id=29&format=feed&type=rss
    custom RSS syndicator :http://extensions.joomla.org/extensions/content-sharing/rss-syndicate/6392 ,for aggreagtion 'News feeds' component can be used, there are otehr componets that can be checked at JED
  13. Integrating aweber auto responder script
Controlling Articles

  1. To show articles in a module use 'news flash module'.
  2. To show modules inside articles use load_position plugin
  3. To remove/change copy right text in the bottom 
  4. To add Google Analytics to Joomla 
  5. Control frontpage parameters (no columns etc )
  6. To embed Yourtube vide in article use Qtube plugin(  JED page , demo






Backend:http://docs.joomla.org/Framework

  1. How doest it differentiates betwee users
  2. How ACL works
  3. how could login be emulated
  4. how can i know if a user is logged in and get user details?
  5. How could logout be emulated
  6. How could registration be emulated
  7. How a user record be emulated.
  8. How could a user be deleted
  9. How can a content be added,edited and deleted
Backend coding Tips:
  1. Work flow:http://docs.joomla.org/API_Execution_Order 
  2. joomla1.5 equivalent of sefRetToAbs is JRoute::_($url)
  3. Session handling is done byJSESSION( API,docs link, source ) class.Instance got with &JSession::getInstance();Only needed if to set a session variable or getToken 
  4. A component in MVC framework could be made with files componentname.php,controller.php and folders model,view,helpers,tables,language,images
  5. To write an  independant file in a component
    define( '_JEXEC', 1 );
    define('JPATH_BASE', realpath(dirname(__FILE__)."/../../") );//$mosConfig_absolute_path

    define( 'DS', DIRECTORY_SEPARATOR );
    require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
    require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
    $mainframe =& JFactory::getApplication('site');
    $mainframe->initialise();
    //define('CANERI_TEST_MODE',0);
    $mainframe->route();
    //require_once(realpath(dirname(__FILE__)).'/canaryConfig.php');
    $uri =& JURI::getInstance();
    define('JOOMLA_BASE_URL', substr($uri->base(),0,strpos($uri->base(), 'components/')));



















    How can I get the path to Joomla! (or a component) folder?

    The path to the folder where Joomla! is installed is stored in a constant defined by the framework
    JPATH_SITE
    This constant always contains a path on the server's file system. The statement

















    echo JPATH_SITE;
    will output something like

















    /home/account_name/public_html
    This only an example. If you try to echo the constant on your site, the result will likely be different. If you host your Joomla! site with an hosting company the actual path depends by how they organize user accounts on their servers.
    But all these details are largely irrelevant. Use JPATH_SITE whenever in your code you need to build a path relative to the folder where Joomla! is installed and you will never be wrong.
    While developing a Joomla! component we often need to build a path relative to the folder where the component is installed. We could simply use, for example

















    $mycom_folder = JPATH_SITE . DS . 'components' . DS . 'com_componentname';
    DS means directory separator and is a constant used to build paths that are indipendent from the server's operating system where Joomla! is running. DS is initialized with / in a UNIX/Linux environment and with \ in a MS Windows environment.
    But we also have available a handy shortcut
    JPATH_COMPONENT_SITE
    When used in a file that is part of a component, this constant contains the path to the frontend folder of that particular component.
    There is also
    JPATH_COMPONENT_ADMINISTRATOR
    As it's now easy to guess, we can use this constant in a file that is part of a component to get the path to the backend folder of the component. In other words the constant is equivalent to

















    JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_componentname'
    Here's another one!
    JPATH_COMPONENT
    This constant is equivalent to JPATH_COMPONENT_SITE or JPATH_COMPONENT_ADMINISTRATOR respectively when used in a file that is part of a component frontend or backend.





  6. Other important functions
     Filepaths:
    In Joomla! v.1.5.x the absolute path($mosConfig_absolute_path) is set in the index.php (line 17) file in the base directory to the constant JPATH_BASE.define('JPATH_BASE', dirname(__FILE__) );


    echo $uri->root()."
    "; //root url
    echo $uri->base()."
    "; //base url
    echo $uri->current()."
    "; //current url pathj
    echo JURI::base()."
    ";//$mosConfig_live_site = str_replace("/administrator/","/",JURI::base());*/
    Confiuration Object
    $config = JFactory::getConfig();
    //echo  $config->getValue('sitename');
    Database Object:
    //$db =& JFactory::getDBO();
    /* select query
                   
    $query = "select * from #__canary_search_categories order by category_id";
    $db->setQuery($query);
    //echo $db->_sql."
    ";      
    //$db->query();
    $results = $db->loadAssocList();
    Other Queries:
                   
                    $query = "insert into `#__canary_search_places`(`category`,`title`,`Phone`,`Address`,
                    `City`,`Zip`,`Region`,`country`,
                    `longitude`,`latitude`,`staticMapUrl`,`accuracy`,`rating`,`source`,`Modified_date`)
                    values
                    ($category_id,  $sqlFields '5','0',1,NOW())";
           
           
                    $db->setQuery($query);
                    showSQL();
                    //echo $db->_sql.";\n";    //exit;   
                    $db->query();
                    $placesId =  $formats[$category_id]['place_ids'][$fieldIndex] = $db->insertid();
               
    Get language
    //$lang =& JFactory::getLanguage();
    //echo 'Current language is: ' . $lang->getName();
    //global $_CB_framework;echo $_CB_framework->getCfg( 'lang' ) ;
    Get User Object
    //echo $user->id
    $user =& JFactory::getUser();
    //echo $user->id

    pre array or var:JUtility::dump()


            MAIL:
    JUtility::sendMail();

    or

    jimport('phpmailer.phpmailer');
            //$mailer = new PHPMailer();
            /*jimport('joomla.mail.mail');
            $mailer = new JMail()*/
            $mailer = & JFactory::_createMailer();
            $shareLink =  JOOMLA_BASE_URL.'/index.php?option=com_canarysearch&isSharedSearchPage=true&'.$_REQUEST['searchAddress'].'&shareId='.$_REQUEST['shareId'].'&task=sharedPage';
            $HTMLMsg = "please visit this ".$shareLink."";
            //echo $shareLink; exit;
            $mailer->From = $_REQUEST['youremail'];
            $mailer->FromName =  $_REQUEST['yourname'];
            $mailer->AddAddress($_REQUEST['email']);
            $mailer->Subject = "Check this page at ".$config->getValue('sitename');
            $mailer->Body =$HTMLMsg;
            $mailer->IsHTML(true);
            $mailer->AltBody= strip_tags($HTMLMsg);
          
            if ($mailer->Send() !== true)
            {
                // an error has occurred
                // a notice will have been raised by $mailer
                echo $shareLink;
                //echo 'There was a problem sending this mail!';

            }
            else
            {
                //echo $shareLink;
                echo "Mail send successfully";
            }
            exit;
            Date
            $date =& JFactory::getDate();
            $date = $date->toMySQL();
  7. Create encrypted password
    $salt = JUserHelper::genRandomPassword(32);
    $crypt = JUserHelper::getCryptedPassword("blabla", $salt);
    $password = $crypt . ':' . $salt;
    Add a user in backend with username and password only

            $email = $_POST['email'];
            $passwd = $_POST['passwd'];
            $password = md5($passwd);
            $full_name = $email;
            $username = $email;
            $usertype = 'Registered';
            $gid = 18;
            $date = $date->toMySQL();
            //check if username exists
            $db =& JFactory::getDBO();
            $query = "select * from #__users where username='$email'";
            $db->setQuery($query);
            //$db->query();
            $results = $db->loadAssocList();
            //echo "



















































    ";print_r($results);echo "
    ";exit;
            if(count($results ) >0)
            {
                echo "Username '$email' already exists'";
                exit;
            }
            else //if(count($results ) >0)
            {
                        $query = "INSERT INTO #__users (name,username,email,password,usertype,gid,registerDate)
                    VALUES
                    ('$full_name', '$username', '$email', '$password', 'Registered', '18', '$date')";
                $db->setQuery($query);
                showSQL();
                $db->query();
                $userid = $db->insertid();
                $query = "INSERT INTO #__comprofiler (id,user_id)
                        VALUES
                    ('$userid', '$userid')";
                $db->setQuery($query);
                showSQL();
                $db->query();

                /*
                #__core_acl_aro:id     section_value('users')     value($userId)     order_value(0)     name($username)     hidden(0)*/
                $query = "INSERT INTO #__core_acl_aro
                        (id,section_value,`value`,`order_value`,`name`,`hidden`)
                        VALUES
                        ('', 'users', '$userid', 0,'$username',0)";
                $db->setQuery($query);
                showSQL();
                $db->query();
                $aro_id = $db->insertid();
                /*
            #__core_acl_groups_aro_map :group_id(18)     section_value ('')    aro_id ($aro_id);
                */
                $query = "INSERT INTO #__core_acl_groups_aro_map
                        (group_id,section_value,aro_id )
                        VALUES
                        ($gid, '', '$aro_id')";
                $db->setQuery($query);
                showSQL();
                $db->query();
                $usersipass['username'] = $email;//'admin';//$user->get('username');
                $usersipass['password'] = $passwd;//123456;
                $loginResponseObj = $mainframe->login($usersipass);

                echo "Registration completed successfully";
                exit;
            }//if(count($results ) >0)
            /**/





































  8. login with AJAX
            //$_SERVER['QUERY_STRING'];exit;
            //usinng code from
            //http://www.gjcwebdesign.com/nl/joomla-15-automatic-login-after-registration.html
            $usersipass['username'] = $_REQUEST['username'];//'admin';//$user->get('username');
            $usersipass['password'] = $_REQUEST['passwd'];//123456;
            $loginResponseObj = $mainframe->login($usersipass);
            //echo (trim($loginResponseObj->message) =='d');exit;
            if($loginResponseObj->message)
            {
                echo $loginResponseObj->message;
            }
            else
            {
                echo "Sign in successfull";
            }
            exit;
  9. Add breadcrumb
            //$mainframe->appendPathWay('Local Search');
  10. Edit /Delete Bread crumb nodes
             $cmsPathway =& $mainframe->getPathway();
             if($cmsPathway->_pathway[0]->name =="Shop")
             {
               unset($cmsPathway->_pathway[0]);
             }
            
  11. Change page title
            //$mainframe->setPageTitle('Local Search');
  12. Load Javascript and css(bundled with core cms)
                http://docs.joomla.org/Adding_JavaScript_and_CSS_to_the_page 
               
                JHTML::script('joomla.javascript.js', 'includes/js/', false);
                JHTML::script('mootools.js', 'media/system/js/', false);
                JHTML::script('modal.js');
                JHTML::stylesheet('modal.css');
  13. pclzip is available at administrator/includes/pcl/pclzip.lib.php : details here
               
      

           





Programming Core CMS

  1. Steps of Skinning : See Templates below
  2. Steps for customizing menus
  3. Steps for creating an extention:Extenstion Type:Details
    Component:
    http://www.vojtechovsky.net/joomla/component-helloworld-2-create-tutorial-guide-en.html
    http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
    Module
    http://docs.joomla.org/How_to_create_a_module
    Custom module Development http://help.joomla.org/content/view/20/125/
    Plugins:System Events
    Authentication Plugin:http://docs.joomla.org/Tutorial:Creating_an_Authentication_Plugin_for_Joomla_1.5
    content plugin
    http://developer.joomla.org/tutorials/184-how-to-create-a-joomla-plugin.html

    All Plugins: http://forum.egypt.com/enforum/articles-f141/how-create-joomla-plugin-18810.html
    Types of Plugins:
  4. Authentication
  5. Content
  6. Editors
  7. Editors XTD (Extended)
  8. Search
  9. System
  10. User
  11. XML-RPC
    Templates:http://docs.joomla.org/Tutorial:Creating_a_basic_Joomla!_template
    http://developer.joomla.org/tutorials/33-tutorials/165-understanding-output-overrides-in-joomla.html

    displaying component messages < jdoc:include type="message" / >
    in component controllers $this- >setRedirect($link, $msg);

    $this- >setTitle(html_entity_decode($mainframe- >getCfg('sitename'). ' - ' .$this- >title));

    setting 'base'  tag  with $this- > setBase( '/' ); when artio sef component is used

    Javascript features available:JHTMLBehaviour:http://api.joomla.org/__filesource/fsource_Joomla-Framework_HTML_joomlahtmlhtmlbehavior.php.html
    1. adminside toolbars
    2. mootools lightbox(Squeezebox) http://digitarald.de/project/squeezebox/
      JHTML::_('behavior.modal')
      use

      rel="{handler: 'iframe', size: {x: 900, y: 500}}" in 'a' tag

      To custom open use


      <a href="link" rel="{handler: 'iframe', size: {x: 900, y: 500}}" onclick="return showModal(this);" >View Selecteda>


      function showModal(aObj)
             {
              //alert(aObj.href);
            
              SqueezeBox.fromElement(aObj);
              
              var scrollTop = document.documentElement.scrollTop;
              
              if(navigator.userAgent.indexOf("MSIE") > -1 )
              {
               document.location = "#top";
              }
              
             
              return false;
             }


      To close use

      window.parent.document.getElementById('sbox-window').close();
      OR
      window.parent.SqueezeBox.close()
    3. datebox

      JHTML::_('behavior.calendar');

      then for your date field in your form:

      <   input class="inputbox" type="text" name="startdate"
      id="startdate" size="25" maxlength="25"
      value=""   /  >
      <  input type="reset" class="button" value="..."
      onclick="return showCalendar('startdate','%Y-%m-%d');" /    >

    4. tooltip:
    5. AJAX http://docs.joomla.org/Ajax_using_MooTools
      this explains only get method for post the change requried is
       method: 'post',data: $('idOfForm')
    6. To show content without template html use &format=raw .The same effect cacn be cuased with the codes below in controller as in ,http://forum.joomla.org/viewtopic.php?p=1936378
            $document = &JFactory::getDocument();
            $document = JDocument::getInstance('raw');

            parent::display();
    7. validation tools?(email,number,website etc) http://docs.joomla.org/Form_validation
      is done with motools.js and validate.js

      remember to set the following in template.css

      .invalid{ color:red !important;}
      .form-validate label { font-size:12px;}

      And

          $script = '';
          $document =& JFactory::getDocument();
          $document->addScriptDeclaration($script);
    8. creating tabs
    9. WYSWYG editor for text area
      < ? php
      $editor        =& JFactory::getEditor();//http://docs.joomla.org/JFactory/getEditor                         // parameters : areaname, content, width, height, cols, rows,show buttons( image,pagebreak,readmore )
      echo $editor->display( 'header', $row->header , '500', '250', '75', '20' ,false) ;
      ?>




      and in javascript form validation/submit script
                     <?php






      // var headerContent = getContent( 'header' )?>
      //alert(headerContent);
      <?php echo $editor->save( 'header' );?>
      // alert(form.header.value);

                      ?>
                     
      just above submitform( pressbutton );

      When you false for show buttons( image,pagebreak,readmore ) add the following CSS
      <style type="text/css">
      .button2-left{
      margin:10px 0px 10px 0px;/*to reposition 'Toggle editor' button which otherwise will jump upwards when other buttons are disabled */
      }</style>

      in backend/controller if you are using JRequest::get('post') add JREQUEST_ALLOWHTML to make it






      JRequest::get('post', JREQUEST_ALLOWHTML))
       



    Popular Extensions

    1. Ecommerce:Virtuemart:download , svn details
    2.  ; tutorial
    3. SEO:   artio: download  ,tutorials  FAQ  demo is insure-your-mobile.co.uk,sh404(now commercial): download ; tutorials:(to have urls ending with .html,it has to be set explicitly in "Configuration edit File suffix"
    4. Blogging: component list,smart blog :download ,tutorial,demo
    5. Gallery:component list ,
    6. Calendar:component list
    7. Forums: component _list, Kunena ; Agora,fireboard(currently abandoned);
    8. Newsletter:Acajoom , aweber integration .
    9. Directory Listings:SOBI :component download , extensions download
    10. Social neworking:joomsocial (commercial ): buy-now.html    demo , documentation
    11. Multi language: Joomfish: download , Tutorials ,Tutorial(with virtuemart)  .(components >> joomfish.Then click 'translations tab' )
    12. Other: 
      1. Content Comment tool:Jcomment article category is selectd to have comment feature.if an article doesnt need this feature it should be in a different category
      2. Export and import contents : http://extensions.joomla.org/extensions/4054/details
      3. Custom Form creation from admin: JED listFabrik ;ChronoForm: download , tutorial , tutorial 2 ,
      4. Community builder:downloadplugin development , download helloworld plugin login required to download
      5. Captcha :JED list
      6. Downloads Management:Phoca download (after installing edit function getPhocaId($id){ in dministrator\components\com_phocadownload\helpers to get rid of the footer set by phoca guys); JED list
      7. Glossary & Dictionary:Component List , Glossary
      8. File management
        eXtplorer(1.5 native)(Good but starts with DOCUMENT _ROOT,needs to be changed to show from joomla home), 
        for that edit administrator/components/com_extplorer/include/init.php
        change line $GLOBALS['home_dir'] = !empty( $_SERVER['DOCUMENT_ROOT'] ) ? $_SERVER['DOCUMENT_ROOT'] : '.';

        to
        $GLOBALS['home_dir'] = realpath(JPATH_BASE."/../");//!empty( $_SERVER['DOCUMENT_ROOT'] ) ? $_SERVER['DOCUMENT_ROOT'] : '.';

        ,Joomla explorer(1.5 legacy only) ,
      9. backup :component_list; JoomlaPack (good for downloading sites whenthere are customization projects),just download the zip and call the joomla path and it will show the joomla pack installer screen(not core joomla installer),change database setinngs and proceed clicking 'Next" and you are done.- JoomlaCloner(GOOD to install in aremote site) - LazyBackup 2 
      10. database management :
        backup with System - JBackup ,
        Enable plugin
        set paremeters
        '
        Download with Cron' to Yes
        'Send Mail' to No
        Apply and click 'Execute Cron Link'

        run sql with easy sql component
          component_list 
      11. Auction module : JED list  ;
      12. Jumi : tutorial  enable to include php, html, javascript scripts into the modules position, articles, category or section descriptions, or into your own custom made component pages
        Jumi

      13. Jobline
      14. Hotel Booking : joomres
    PS:
    SVN of joomla 1.6 is available at http://joomlacode.org/svn/joomla/development/trunk/ username:anonymous

    http://www.blogingbloging.com/download-latest-version-joomla-16/ 
     
    It is actually pretty straight forward, let me give an example of a command line export on Ubuntu (subversion client is installed of course).
    cd /var/www
    svn export http://joomlacode.org/svn/joomla/development/trunk/ --username anonymous
    Authentication realm:  Document repository
    Password for 'anonymous':
    
    
    As you can see we do a checkout from the 1.6 trunk location (http://joomlacode.org/svn/joomla/development/trunk/) and use anonymous access to retrieve the repository. There are several different clients available that can read the subversion repository on a variety of platforms (Windows, Linux, MAC). Under windows you can use for example Turtoise SVN, all you then need to do is to right-click on a folder in the explorer en you can select the export option.

    Subversion Terminology 
    Developer tools
    Template wizard:
    Component creater:
     Non Joomla tools

    Creating custom components
    1. create a basic file structure with http://www.notwebdesign.com/joomla-component-creator/
    2. create required database tale for the first section of the component(add fields id,published,ordering)
    3. create admin menu entry of the section by manually inserting  a record into jos_components
    4. Create tool bar
    5. Add required values in component's config file
    6. create controller,view with display,search,delete,publish,unpublish options
    7. create model and table classes appropriately
    8. add static functions in helper class appropriately

    3 comments:

    1. Thanks for the tips. Usually, I do not post on blogs, but I wish to say that this post really forced me to do so! Thanks, incredibly nice article. Thank you lots, I am obliged to announce that your blog is excellent!
      Joomla RSS Feed Extension

      ReplyDelete
    2. Your blog is really excellent.It inspires the readers.Thanks for sharing information .
      web design and development company | mobile apps development companies melbourne

      ReplyDelete
    3. The best design of website could making in only joomla tutorials.Because i designed one website in joomla tutorials.It was very nice compared to other tutorials websites.Website Design Company Bangalore | Web Development Company Bangalore

      ReplyDelete