Wednesday, May 2, 2012

Mootool Validation for Form Field

To Display a label if field value doesn't exists on submit the form we can use mootool validation as follows.

//Example Form Field

<input type="text" size="30" class="required invalid" value="" id="jform_contact_name" name="jform[contact_name]" aria-required="true" required="required">
<span style="display:none;color:#993300;margin-left: 111px;" id="jform_contact_name-lbl_id">Enter Name</span>


How To Limit Your Text’s Characters using PHP

Limiting a text characters is displaying a limit number a characters from a text ( not to show all the text )

The function we will use for that is substr and the syntax is:

substr($message, start, length) ;

$message : we put the text into that variable.

Start : Where you want to start dislaying text from ( put the number of character starting by 0 ).

Length : Define how many character you want to display.

( be sure that the Length is less than the text character’s number !)

Example1

< ?php

$length = 12 ;
$text = "Learn PHP With MistreX" ;
$display = substr($text, 0, $length) ;
echo $display;
echo "..." ;

?>

Hello,

To change this? <meta name="Generator" content="Joomla 1.5">
from joomla tempalte.

Goto your template and add the following:

 
$document = &JFactory::getDocument();
/* @var $document JDocument */
$document->setGenerator('');

Show a particular joomla module in external file

Show a particular joomla module in external file

Show a particular module in external file



define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__));
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();
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule('banners');
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
echo $renderer->render($module);

how to add custom registration field in joomla extend joomla registration in com_users

Once in a life, everybody needs something extra and when it comes to Joomla, it is really easy as there are many extensions available for Joomla but when it comes to extend Joomla registration in frontend and managing the same way in backend then it gets difficult and I faced this when I was working today over a Joomla project so I thought to prepare a note for future use as well as to share with rest of the community. (may be there are similar solutions already but this is how I solved it.)

My example shows how to add an extra field called company in Joomla registration:

---------------------------------------------------------------------------
Step 1. Add DB field variable to user.php

Please open file as below:

YOUR_SITE/libraries/joomla/database/table/user.php

and declare the variable as below to connect with the relevant field in database table for users i.e. jos_users

How to Add CSS/Javascript to Your Joomla Extension

This article applies to Joomla! 1.5 development. This information is subject to change in Joomla! 2.5

When writing your custom component or module, more often than not, you will want to include your own CSS or Javascript code. If Joomla! did not provide an easy way to do this, you would be forced to use script tags throughout your code. While this approach would technically work, the best practice is to put all scripts inside the head tag of your page. How is that possible when the of your page is only seen on your template index.php file and you're developing a new module or component? The JDocument class is the answer. Let's look at the easiest way to go about doing this.

First we need to grab the JDocument object:

$document = JFactory::getDocument();

Now let's add a stylesheet:

Display name instead of username in Who is online module

If you want to display the name of the user instead of the username in the Who is online module, you need to do the following steps. The module gets the data from the session table, but that table doesn't contain the name of the user, only the username and the userid. That's why you need to join the session and the users table in the sql query. For this open the /modules/mod_whosonline/helper.php file and change


$query = 'SELECT DISTINCT a.username' .
  ' FROM #__session AS a' .
  ' WHERE client_id = 0' .
  ' AND a.guest = 0';

To

Adding Custom Field in com_content

Hi Everybody,

I am several hours into this problem and looking at this post. Finnaly I think I have what I wanted. So lets say I want to add a custom field named "url" so my users could submit on every article an "url" field with some link:

1-changed joomla database in "jos_content". Using phpmyadmin I executed this query

ALTER TABLE `jos_content` ADD `url` MEDIUMTEXT NOT NULL