Wednesday, March 30, 2016

Fixed - Document Expired when using back button of browser

Searched a bit and found this proposed "solution":

<?php session_cache_limiter('private_no_expire'); // must go before session start session_start(); ?>

For details, see http://php.net/manual/en/function.session-cache-limiter.php

Found here: https://support.mozilla.org/en-US/questions/922734?page=2

More possible solutions and info here: http://stackoverflow.com/questions/10795552/php-document-expired

Redirect url with dynamic server address in .htacess

To make it more dynamic lets use SERVER_NAME and REQUEST_URI instead of a static domain name. This is the way to redirect to HTTP non-www to HTTPS www htaccess.

RewriteEngine On

#we replace domain.com/$1 with %{SERVER_NAME}%{REQUEST_URI}.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) http://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

#here we dont use www as non www was already redirected to www.
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
 
 

Friday, March 18, 2016

Joomla default search module

Every web site has a search box because there is no point writing great content on your web site if no one can find it. Usually the search box is in the top right hand corner of your web site. If we put in the secret url ?tp=1 we can see that there is a position up here in the top right called position-0 and we're going to use that for our search box. 

In the administrator go to Extensions and Module Manager Now click on New and we can see a long list of all the modules that Joomla is shipped with. Here is one called Search Click on that to select it. We now need to give the module a title so that we can find it again. Search is as good as any. Place the module in the position that we just found which was Position-0. Click Save. Return to your web site remove that secret url and the search box is here. If we click inside the search box and do a search we can see all the results. 

Now currently you will notice that the search also gives you the option to search only in the following parts of your web site. Categories, Contacts, Articles Newsfeeds and Weblinks. We're only using Articles and Contacts on this web site so we can remove the ability to search inside of Categories, Newsfeeds and Weblinks. It will just tidy up the web site a little. 

Go to : Extensions > Module Manager > New > Search

Thursday, March 10, 2016

Joomla 3 - Get article intro Image by article Id


Here the following post is useful to get article images from the article id in joomla3.

$article_id = JFactory::getApplication()->input->get('id'); // get article id

$article = JTable::getInstance("content");
$article->load(JRequest::getInt("id")); // Get Article ID
$article_images = $article->get("images"); // Get image parameters
$pictures = json_decode($article_images); // Split the parameters apart

// Print the image
echo "<img src='" . $pictures->image_intro . "' alt='" . $pictures->image_intro_alt . "'>";

Good Luck!! Cheers :)