Hacking web things

This Joomla 3.x plugin displays bibliographies from libraries made publicly available on zotero.org. To insert a bibliography in your content write something like {zotbib author="Wittgenstein" itemType="book"}. This will be replaced by a formatted list of all the books authored by Wittgenstein which are in your Zotero library.

Source code and detailed instructions at https://framagit.org/svictor/j3-zotbib.

Zip the files together (or choose the "download zip" option) to install it to your Joomla 3.x website.

Jevents is a Joomla addon to manage events in a calendar. Jevents comes with a module used to display selected events (forthcoming, latest etc.) on any page of the website. The module can display the title of the event, its description etc. However, it cannot natively display however an image inserted in the event’s description. My plugin allows for this.

When making websites with Joomla, I sometimes need to indicate the subcategory titles in category blogs.  The result should look like this:

 Subcat title A
Article 1
Article 2
Article 3

Subcat title B
Article 1
Article 2
Article 3

Subcat title C
Article 1
Article 2
Article 3

On the current website that’s how my publication list is formatted (Books, Edited volumes, Articles etc. are all subcategories of Publications).

Joomla can sort the articles by subcategory, but doesn’t output the subcategory title above the relevant set of articles. I made an override for blog.php for that. It's here on github.

Nowadays most Joomla components give access to ACL (access control list, basically usage permissions for each user groups) in their backend settings. But some very good ones don’t. This happens for components which have their own interface that completely bypasses Joomla’s. Example: the excellent ProFiles file manager by Mooj.

In the _assets table look for the line with your component name (in our case com_profiles). The rules should contain an empty array {}. If it’s not empty, it probably means that there is a permissions tab somewhere and you have missed it. Go back and look for it. Don’t mess with the database any further. If however the rules are just {}, insert instead something like:


Where xx is the id of the user group you wish to enable access for. You get that id from the _usergroups table.

This is convenient especially for modules with a “dynamic” mode, like mod_articles_category. It allows to also change the title dynamically depending on the menu item.

Copy the default.php file from your module's tmpl folder into /templates/your_template/html/name_of_your_module/. Towards the begining of the file (but after "defined('_JEXEC') or die;") add this

// Dynamically assign module title depending on the menu item
// Exclude some modules by adding them to the modexclude[] array
$modexclude = [];
$active = JFactory::getApplication()->getMenu()->getActive();
if ($active && !in_array($module->id,$modexclude)) :
 $module->title = JText::sprintf(htmlspecialchars($active->title));

The code will give dynamic titles to all instances of the plugin, but you can override specific ones by adding their ids to the modexclude[] array (separate with commas).

If you ever set SSL on parts of your site and later change your mind, you may run into trouble to revert to non-SSL. Of course, you have cleared your browser cache. In Firefox you have also right-clicked on the site name in your history and chose “Forget about this site” while no tab had the site opened. But when you type the non-https address, the browser still redirects you to https://

What’s even worse: you set a redirect like this in your .htaccess

## Disable https on public site. Force redirect to http.
RewriteCond %{HTTPS}       on
RewriteCond %{REQUEST_URI} !^(.*)/administrator/(.*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} .
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

And then you screw the browser completely in an infinite loop. Ugly ain’t it?

Well, for one thing it probably occurs only in those browsers which have visited the page while https was on. If you just tested for a short period of time, this could be just yours. But still, you need to solve the problem. Try inserting the following line in your .htaccess (above the previous redirect block if using it).

## Unset
Header set Strict-Transport-Security "max-age=0"

If that works and you want to know why, read on here.

See: http://www.en.joomgallery.net/faq/general-faq/show-image-description-in-slimboxthickbox.html

On Community builder pages (and possibly all category views popups) :

In components/com_joomgallery/interface.php change this line:

$link .= '" title="'.htmlspecialchars($obj->imgtitle, ENT_COMPAT, 'UTF-8');

to the following:

$link .= '" title="'.htmlspecialchars($obj->imgtitle, ENT_COMPAT, 'UTF-8') .htmlspecialchars($obj->imgtext, ENT_COMPAT, 'UTF-8');

And also this one

$link .= '" title="'.htmlspecialchars($img->imgtitle, ENT_COMPAT, 'UTF-8');

to the following:

$link .= '" title="'.htmlspecialchars($img->imgtitle, ENT_COMPAT, 'UTF-8') .htmlspecialchars($img->imgtext, ENT_COMPAT, 'UTF-8');

[Subtle difference between the two : in 1st case the object is referred to as $obj and in the second as $img]

Joomgallery module has an option to wrap text (title, author, description...) but you have to specify the number of characters. This is not practical if your images have varying widths, especially if some are in landscape and others in portrait orientation. Here is how to set the output to wrap the text according to the image width.

First disable the wrapping in the module's interface, by setting the value to 0 (for title and description).

Then, in modules/mod_joomimg/helper.php, Look for the last occurence of $imgWidth. It should be in function modcontent(&$objects). Put this on a line after all if parenthesis {} are closed. The value of $imgWidth is calculated differently depending on some parameters. We need to get it after this, but before the end of the function:

$GLOBALS['largimage'] = $imgWidth;

This inserts the value in the $GLOBALS array, making it available for other functions.

Then in function rendercss(), find the line underlined below 

$css .= '.'.$csstag.'imgct {'."\n"
        . 'width:'.$containerwidth.'% !important;'."\n"
        . $csscont

And replace it with

        . 'width:'.$GLOBALS['largimage'].'px !important;'."\n"

That's it! The container now has the exact width of the image.


If you use joomgallery module to display random images uploaded by your users, you can easily display the author's name (that's in the module's options). But it appears in plain text. If you want to have it as a link to their profile, here is how.

Option 1: Use the JoomDisplayCBName plugin. It's actually the easiest and most complete way to do it... But I didn't know about it until after I had tweaked the php code. So I leave the 2nd option below, just in case.

Option 2: In components/com_joomgallery/interface.php, comment out the line which says

$output .= " <li>".JText::sprintf('COM_JOOMGALLERY_COMMON_AUTHOR_VAR', $authorowner);

And replace it by

$lienauteur = "<a href=\"index.php?option=com_comprofiler&task=userprofile&user=$obj->owner\"> $authorowner </a>";
$output .= "  <li>".JText::sprintf('COM_JOOMGALLERY_COMMON_AUTHOR_VAR', $lienauteur);

Of course the href url should be adapted if you use another user manager than community builder.

Problem: we want the styles of, say, the titles or the backgrounds to depend on the chosen menu item.

Solution: in Joomla 2.5 it's as simple as :

<div class="menuid_<?php echo (JRequest::getInt( 'Itemid', 1, 'get' )); ?>"

Then in the css file we just style .menuid_X and its children (X being the id of the menu item).

This is a template override for Joonla 2.5 to split Category blog layouts by category with their respective titles. Joomla 2.5 does sort the articles by categories if instructed to do so in the menu item's options, but it does not display the Subcategory titles when needed. I couldn't find an extension to do that. A simple layout override is enough however.