Jommla w szkole

By widzieć więcej...

  • Full Screen
  • Wide Screen
  • Narrow Screen
  • Increase font size
  • Default font size
  • Decrease font size

Joomla Api Doc

PHP Object Class Array

$book = new stdClass;
$book->title = "Harry Potter and the Prisoner of Azkaban";$book->author = "J. K. Rowling";
$book->publisher = "Arthur A. Levine Books";
$book->amazon_link = "http://www.amazon.com/dp/0439136369/";
print_r($book);
$tab = (array) $book;
print_r($tab);
$array = array(
"title" => "Harry Potter and the Prisoner of Azkaban",
"author" => "J. K. Rowling",
"publisher" => "Arthur A. Levine Books",
"amazon_link" => "http://www.amazon.com/dp/0439136369/"
);
$books = (object) $array;
print_r($books);

JRoute

echo JRoute::_('index.php?option=com_komponent&task=view&id='.$kategoria->id);

Manifest.xml - parametry

From Joomla! Documentation

  • calendar provides a text box for entry of a date. An icon next to the text box provides a link to a pop-up calendar, which can also be used to enter the date value.
  • category provides a drop down list of categories from a given section.
  • editors provides a drop down list of the available WYSIWYG editors.
  • filelist provides a drop down list of files from a specified directory.
  • folderlist provides a drop down list of folders from a specified directory.
  • helpsites provides a drop down list of the help sites for your Joomla installation.
  • hidden provides a hidden field for saving a parameter whose value cannot be altered directly by a user in the Administrator (it can be altered in code or by editing the params.ini file).
  • imagelist provides a drop down list of image files in a specified directory.
  • languages provides a drop down list of the installed languages for the Front-end or Back-end.
  • list provides a drop down list of custom-defined entries.
  • menu provides a drop down list of the available menus from your Joomla site.
  • menuitem provides a drop down list of the available menu items from your Joomla site.
  • password provides a text box for entry of a password. The password characters will be obscured as they are entered.
  • radio provides radio buttons to select different options.
  • section provides a drop down list of the sections from your Joomla site.
  • spacer provides a visual separator between parameter field elements. It is purely a visual aid and no parameter value is stored.
  • sql provides a drop down list of entries obtained by running a query on the Joomla Database. The first results column returned by the query provides the values for the drop down box.
  • text provides a text box for data entry.
  • textarea provides a text area for entry of multi-line text.
  • timezones provides a drop down list of time zones.
  • usergroup provides a drop down list of user groups.

addStyleSheet, addScript

// addStyleSheet

$doc =& JFactory::getDocument();
$doc->addStyleSheet( 'http://www.example.com/css/mystylesheet.css' );
//for the templates:
$this->addStyleSheet( 'templates/' . $this->template . '/css/mystylesheet.css' );

//deklaracja stylu

$doc =& JFactory::getDocument();
$style = 'BODY {'
. 'background: #00ff00;'
. 'color: rgb(0,0,255);'
. '}';
$doc->addStyleDeclaration( $style );

// addScript

$doc =& JFactory::getDocument();
$doc->addScript("http://www.example.com/js/myscript.js");

//feklaracja skryptu

$extrascript = 'alert( \'Hello Joomla!\' )';
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration( $extrascript );

//addCustomTag

$document =& JFactory::getDocument();
$document->addCustomTag("");

//CSS style sheets

$document->addHeadLink("components/com_helloworld/moolet/mootips.css", "stylesheet", "rel");




INNE

$document =& JFactory::getDocument();
$moje_pliki = JPATH_SITE.'modules'.DS.'mod_floom'.DS;
$document->addCustomTag(''); $document->addCustomTag(' google.load("mootools", "1.2.4");'); $document->addCustomTag(''); $document->addCustomTag('');
$document->addHeadLink($moje_pliki.'floom.css', 'stylesheet', 'rel');
$extrastyl=$params->get('art_css');
$document->addCustomTag(''.$extrastyl.'');
$extraskrypt='var zmienna=1;';
$document->addCustomTag(''.$extraskrypt.'');
$href = 'index.php/other/css/mycss.css';
$attribs = array('type' => 'text/css');
$document->addHeadLink( $href, 'stylesheet', 'rel', $attribs );

$$ Multi selector

$$('a');    //returns all anchor elements in the page
$$('a', 'b');    //returns all anchor and bold tags on the page
$$('#myElement');    //returns an array containing only the element with the id 'myElement'
$$('#myElement a.myClass');    //within the DOM element with id 'myElement'
$$(myelement1, myelement2, 'a', '#myid, #myid2, #myid3');    //creates an array of all elements and selectors passed as arguments

$$('a[href^=mailto:]');    //returns all mailto links
$$('input[type=text]');    //returns all text fields
$$('#form input:checked');    //return all elements that are checked within #form
$$('p:contains("Justin")');    //returns all paragraphs with my name
$$('input:not([type="submit"])');    //all input fields except buttons
$$('a[rel=external]').set('target', '_blank');    //set external links
$$('#table td:even');    //get all even table rows for #table

$$('table > tr:even').addClass('even');
$$('table > tr:odd').addClass('odd');

MenuID, ArticleID

$menus = &JSite::getMenu();
$menu  = $menus->getActive();
$itemid = $menu->id;


$varID=JRequest::getVar('id');
$arrID=explode(':',$varID);
$artID=$arrID[0];
$artAlias=$arrID[1];



Templates - szablony - component

component.php - wykorzystywany w wyświetlaniu pojedynczego komponentu (np. index.php?option=com_content&id=75&tmpl=component).
Pomijane są wówczas wszystkie moduły
np: Jak wydrukować...

Behavior.mootools

This removes any Joomla default Scripts from the Header Buffer 
$header = $this->getHeadData();
$header['scripts'] = array();
$this->setHeadData($header);

Inaczej (jak dodać na stałe skrypty)
JHTML::_('behavior.mootools');
$document = &JFactory::getDocument();
$document->addScript(JPATH_SITE.'/media/system/js/jquery.js' );
$document->addScript(JPATH_SITE.'/media/system/js/thickbox.js' );
$document->addCustomTag( 'jQuery.noConflict();' );
$document->addStyleSheet( JPATH_SITE.'/media/system/css/thickbox.css' );
http://fragov.com/blog/2009/10/21/replace-standart-joomla-mootools-with-yours-on-front-end/

//Dodaj TIPSy
JHTML::_( 'behavior.mootools' ); $ajax = "/* 
var Tips3 = new Tips($$('.Tips3'), {
        showDelay: 400,
        hideDelay: 400,
        fixed: true
});
/* ]]> */
";
$doc = & JFactory::getDocument();
$doc->addScriptDeclaration( $ajax );

Rendering modules

Loading a Module Position

The simplest case is to include the modules in a position.  This could be a regular position but you would usually create a special module position just for the layout (or set of layouts) you are overriding.  Here is the code you would place in your layout override.

loadRenderer('modules');
    $options	= array('style' => 'xhtml');
    $position	= 'article-banners';
    echo $renderer->render($position, $options, null);
?>

What we are doing here is loading the document, loading the "modules" renderer from from the document, setting the module "style" (raw, xhtml, etc) and then outputing the desired module position.

Loading a position is very convenient because you can use the Joomla administrator to set all your module parameters.

Loading a Single Module

Loading a single module requires a little more thought because you have to define all of the parameters by hand.  If you don't, you are at the mercy of whatever the developer has set in the module.  The code we use to load a single module is like this:

loadRenderer('module');
    $options	= array('style' => 'raw');
    $module		= JModuleHelper::getModule('mod_comments_comments');
    $module->params	= "heading=2\nlimit=10";
    echo $renderer->render($module, $options);
?>

Again we are getting the document but this time we load the "module" render.  We set the style in the same way as for loading a module position.  Now what we do is use the JModuleHelper to load the actual module by its name (the directory name of the module or the name).  This returns a module object.  We then set the params property of the module in "ini" format, separating each parameter with the newline character "\n".

JPath

JURI::base()
JPath is used to get the directory path.
DS -- is used as a directory separator.JPATH_BASE -- sets the entry to joomla /Joomla
JPATH_CACHE --Sets the cache path /Joomla/cache
JPATH_COMPONENT_ADMINISTRATOR -- sets the backend component path /Joomla/administrator/components/com_example
JPATH_COMPONENT_SITE-- sets the frontend component path /Joomla/components/com_example
JPATH_CONFIGURATION --sets the configuration.php file path
JPATH_INSTALLATION --The path to the installation folder.
JPATH_LIBRARIES --The path to the libraries folder.
JPATH_PLUGINS --The path to the plugins folder.
JPATH_ROOT --The path to the installed Joomla! site.
JPATH_SITE --The path to the installed Joomla! site.
JPATH_THEMES --The path to the templates folder.
JPATH_XMLRPC --The path to the XML-RPC Web service folder.

Strona 1 z 2

You are here: Joomla Api Doc Joomla Api Doc Blog