Skip to main content

Joomla ARTIO SEF set default Itemid for new posts

A small hack to set the default Itemid for new posts added into the admin panel can be done at 2 places in the

file:  components/com_sef/joomsef.php

Line: 1462

                    if (isset($Itemid) && ($Itemid != '')) {
                        $col = ', `Itemid`';
                        $val = ", '171'";
                     // Itemid of the menu item, which is included for almost all modules in our site
                    }

Line: 1567

    if (isset($Itemid) && ($Itemid != '')) {
                                $col = ', `Itemid`';
                                $val = ", '171'";
                            }

Whenever a new article is added in the admin panel, and its link is visited in the front end, a record is inserted into the jos_sefurls table, with the Itemid column value as 1. This can be hacked with the above code modification, to include a custom Itemid for the new url, so that relevant modules are loaded in the new article.

Comments

Popular posts from this blog

php strip all tags

The below function can strip almost all tags from a string. function strip_all_tags($string) {     $string = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $string );     $string = strip_tags($string);     return trim($string); } $a = '<script type="text/javascript" src="jquery.js"></script> <div id="test" style="padding:5px; color:red;">Hello world</div>'; echo strip_all_tags($a); // outputs: Hello world

Joomla validate chrono forms using jquery

It is a common practice to use Chrono forms in our joomla site to setup various forms in the site, be it a contact us form, submit a ticket form, or whatever. I have set the option "validate form" to "No" under chronoform settings in admin panel, and also preferred to not include any js or css files. For validating the chrono forms, i prefer jquery. So first lets add jquery support in our joomla. It is quite simple: 1. Download jquery.js and jquery_min.js (1.4.2 version is enough) and place them in media/system/js folder of your joomla. 2. Edit libraries->joomla->html->html->behavior.php, and add the following function below the mootools() function: function jQuery($debug = null)     {         static $loaded;         global $mainframe;         // Only load once         if ($loaded) {    ...

php get content between tags

This involves parsing the dom document. <?php function getTextBetweenTags($tag, $html) {     $dom = new domDocument;     @$dom->loadHTML($html);         $dom->preserveWhiteSpace = false;     $content = $dom->getElementsByTagname($tag);     $out = array();         foreach ($content as $item)     {         $out[] = $item->nodeValue;     }     return $out; } $xhtml = '<tag>abc def</tag><tag>123 456</tag>'; $content2 = getTextBetweenTags('tag', $xhtml); foreach( $content2 as $item ) {     echo $item.'<br />'; } ?> Output: abc def 123 456