Showing posts with label joomla. Show all posts
Showing posts with label joomla. Show all posts

Thursday, August 17, 2017

Joomla 3: setup to allow registered user to create a post in frontend

Froom Joomla 3.x, you can setup to allow registered user to create a post in frontend without installing any third party extension. Below are steps:

1. Setup ACL (Access Control List) to allow Registered user to create article. Go to System >> Global Configuration >> Articles >> Permission, set Action of Registered to Allowed:


2. Create a menu in frontend for user posting. Remember to select Menu Item Type as Articles >> Create Article and select Access right as Registered:


Now your registered user can create a post, by logging in and clicking the menu (e.g. Create a Post):


However, you should do more steps to customize TinyMCE editor as also as allow user posting HTML content (by default registered user can only post plain text).

3. Enable registered user posting HTML content. Go to System >> Global Configuration >> Text Filters, set Registered group to No Filtering:


4. Customize buttons of TinyMCE editor. Go to Extensions >> Plugins, search TinyMCE then click to configure it:

Open Set 1, drag & drop buttons which you want to appear in the editor for registered user:


To allow empty tags (e.g. <div class="my control class"></div>) in the input content, you can set a value div[*] for Extended Valid Elements field of the TinyMCE editor plugin.

To disable / enable editor xtd buttons like Article, Image etc., you can search its plugin then configure them. For example, to disable button Article (last picture in step 2) for registered user, go to Extensions >> Plugins, search article then click to configure its Access to Special:

5. To receive a notification email when a user create new article, you can use NotificationAry plugin. It is free, just install and enable it. Here is mine:


Yeah! Now you can setup a blog with many users can create articles from frontend then you will get an email notification when having new article and able to approve (publish) it via the link inside the email.

Have dream website! Any comment is welcome!




Thursday, August 3, 2017

Joomla 3.x: Create home page with different content for guests & registered users

When you develop a web application by Joomla 3.x, you may have a need to customize a page with different content for guests & registered users.

For example, I will create a sample web site with different top menu and home page content for guests & registered users. Below are steps:

1. Install & enable OSD Content restriction plugin. This plugin will help to create content in articles based on user access group. So we will use it to load different content for user groups.

2. Create an article for home page. In this article, we input content for guest and non-guest. The following sample will show "This content is only visible to guest users, and NOT visible to registered/logged in users." for guest, and show "This content is NOT visible to guest users. Only logged-in users will be able to see it."  plus the content of a customize HTML module for non-guest (logged user):

3. Create a menu for guest, e.g. Guest Menu. Set up Home menu as Single Article pointing to the article in step 2.

4. Create a menu for non-guest, e.g. Author Menu, all its menu items are set to Registered or other group required logged. Here is a sample:

5. Create modules for showing Guest Menu & Author Menu, put them in same position. Set Access of Guest Menu to GuestAuthor Menu to Public.


6. Done! Let see the home page for guest:

7. Here is the home page for non-guest (logged user):

Yeah! Based on this, you can do what ever you want. Good luck.

Any comment is welcome!

Sunday, July 23, 2017

Playing with template in Joomla 3.x

Template is the heart of Joomla. Almost of things which you need for your website, just do them in your template. In the template, you can override other extensions (components & modules)  without touching to their source code. So you can easily update new versions of the extensions or Joomla without impacting to the front end of your website. This is very important because Joomla community often releases security fixes which you should update immediately for your website if any.

In this article, I will collect & introduce to you some tips which you can play with Joomla's template to setup your website beautifully, quickly and security.

1. Uninstall unnecessary templates

If you don't use a template, let remove it. Less code that means your website is more lightweight, faster and more security. Below the steps to install a template:
  • Go to menu Extensions >> Manage >> Manage
  • Click Search Tools button >> select type as Template >> click the check box of a template wanted to install >> click Uninstall button.

This will remove permanently all source code of the template from your site.

2. Edit source code of a template, code your website on mobile devices

Joomla 3.x provides an editor for editing source code of any template. It is very powerful. I think it is a strength of Joomla against the other CMS. With this editor, you can code your website when you are travelling on mobile devices like smart phone or tablet.
To open the editor for your template, go to Extensions >> Templates >> Templates >> click on the template name:
It will open a screen with files & folders of source code in left side. Here you can do many actions via buttons on the top. Click Documentation button if you want to learn more about this editor. To edit a file, click on its name:


Above are buttons I often use. The right side is source code of selected file. To change for editing the other file, just click on its name. Soo cool 👍

3. Compile LESS file

Another weapon of Joomla is it supports to compile LESS file directly on the template editor. You don't need to install any extra tool. To know what is LESS, let read: http://lesscss.org.

LESS files are often in less folder. If you open a LESS file on the editor, it will show Compile LESS button. After compiling, it will translate into a CSS file corresponding with LESS file in css folder. The template file uses CSS file to present its styles.


4. Create overrides for extensions

In manual way, you must copy the original PHP file from the source of extension into a proper place in your template directory. The correct directory structure for your override file is:
templates/TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php
You can read here for an example.

However in Joomla 3.x, you can also create overrides for extensions by clicking Create Overrides tab then click an extension (module, component, layout) which you want to override in the template manager.


5. Customize Protostar template

As a beginner of Joomla template coding, one of the fastest way is studying & customizing an existing template. What is good template for you starting? I recommend the Protostar template. It is one of the two front-end templates included with a Joomla 3.x source code. Protostar likes a blank responsive template, it is simple but displays well on many devices. So you can build your own template from this template with a basic knowledge about PHP, JavaScript & CSS.

In this section, I give an example on how to create a mobile menu which displays all submenus without touching on parent menu. By default, a submenu will be showed when hovering on parent menu. You can do this action on desktop with mouse, but cannot in a mobile with touching screen. It causes your submenu is never reached on the mobile.

By adding below code into template.less file (in @media query for mobile screen) and re-compile it in the template editor, you will have a proper menu on mobile:

@media (max-width: 480px) {
//start changes
    .navigation .nav-child {
        display: block;
        position: unset;
        float: unset;
        border: unset;
        box-shadow: unset;

        &:before {
            display: none;
        }
    }
    .navigation .nav > li > .nav-child {
        &:before {
            display: none;
        }
    }
//end changes
    .item-info > span {
        display:block;
    }
    .blog-item .pull-right.item-image {
        margin:0 0 18px 0;
    }
    .blog-item .pull-left.item-image {
        margin:0 0 18px 0;
        float:none;
    }
}

Here are screens for desktop and mobile:

It's time to go to bed. Bye everyone! Any comment is welcome.

Tuesday, July 29, 2014

Moving Blogger to joomla

Joomla is a powerful CMS, it lets you make your website/blog running in your way with professional look and feel. And you may have dozen reason to migrate your blog from blogger.com to Joomla if you know Joomla and you have an existing blog on blogger.com.

In this article, I'll share you my experience when I migrated my blog to Joomla. First of all, you should have a plan and overview SOP. Below is my simple SOP:


1. Prepare new Joomla website

I like Joomla 3.x, so I installed latest Joomla version with blank content. Then I choose a template that I love then install it to the new Joomla site.

2. Export / Import content from Blogger to Joomla

There are many ways to do this. You can export XML content from Blogger then import it to Joomla. However I prefer to use FeedGator component to import articles from Blogger to Joomla. FeedGator is free component and you can download here. It imports RSS feedsinto your Joomla! database as content items. It supports full text importing. For Joomla 3.x, you should download FeedGator 3.0 alpha3. Although it is in test phase but you can use it for this importing purpose with my fix here.

After installing, open menu Extensions >> Plugin Manager then enable FeedGator - Joomla Native Content Plugin. Before importing, you should create a category for  imported articles. Go to Content >> Category Manager ans create one (e.g. Joomla!). Now it's time to add the feed of your blog. Open Components >> Feed Gator >> Manage Feeds, click New button to add new feed. Below is a sample screen shot:

In which, Feed URL is gotten from the RSS feed at the bottom of your blog where has Subscribe to: Posts (Atom) link. In above picture, it is my blog RSS feed: http://blog.vivavivu.com/feeds/posts/default. The next is Publishing tab, you can set as the following:

In Text Handling tab, remember to choose Get Source Full Text as Yes.

If you want to download images to Joomla website, let set as below in Images and Enclosures tab:

Because you migrate your blog, so let link back (track back) option in Links tab as No:

You can change another configurations if needing, then click Save & Close button. To import, select the feed which is just created, then click Import button, see the following picture for example:

3. Organize new content on Joomla

After importing content from your blog to Joomla, let check the imported content, imported images. You may edit a little to adapt your articles with new template on Joomla. You may change the structure of menus etc.

4. Redirect 301 old URLs on Blogger to new URLs on Joomla

To keep Google ranking for your articles, you should make 301 redirection from old URLs on Blogger to new URLs on Joomla.

If your blog don't have private domain/sub domain, let configure a private domain/sub domain for it before you migrate. Keep your blog run at least 2 weeks on the private domain/sub domain, it helps Google migrate rankings from its blogspot.com to this private domain/sub domain (e.g. blogger.yourdomain.com).

There are 2 cases for this situation:

  1. You want to keep current domain (blogger.yourdomain.com).
  2. You want to move to new domain (e.g. joomla.yourdomain.com)

4.1 Keep current domain

There are many solutions, below is my way:

  1. Move your old blogger domain (blogger.yourdomain.com) to a real host (support PHP + MySQL)
  2. Install Joomla for the domain
  3. Import old content to a category
  4. Use Redirect component of Joomla (menu Components >> Redirect) to redirect all old URLs to new URLs
  5. After 2 weeks, let check Google search

4.2 Move to new domain

Below are steps:
  1. Install new Joomla on another domain/sub domain (e.g. joomla.yourdomain.com). 
  2. Import old content to new Joomla website
  3. Move your old blogger domain (blogger.yourdomain.com) to a real host (e.g. Windows server + IIS + URL Rewrite)
  4. Redirect 301 all old URLs to new URLs on joomla.yourdomain.com. In the case of you use IIS and URL Rewrite module, here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect to new URL" stopProcessing="true">
                    <match url="^oldURL$" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^blogger\yourdomain\.com$" />
                    </conditions>
                    <action type="Redirect" url="http:/joomla.yourdomain.com/newURL" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

5. Use this tool to check old URLs, make sure that them are redirected 301 correctly.
6. Keep these re-directions at least 2 weeks for Google transfering its rankings to new URLs
7. Check Google search and turn off your old blog if you see OK.

Thanks for reading! Your comments and questions, and shares are welcomed and appreciated! Do you have a blog?

Thursday, June 26, 2014

Joomla: plugin for enhancing security rule on login and password

If you are using Joomla, you may want to protect your administrator area from eyes of bad guys, and you may also want to lock an user after some times of failed login. This help your users and website more secure under attacks of hackers in order to stolen your users' information or serve their ploys.

You can read this my article for hiding your Joomla back-end or use my plugin called V4 Security (support Joomla 3.x, 2.x). You can download it here. Below are its features and illustrate images.

1. Backend Protection

If you key Login Token here (e.g. hung123, you must access your back-end via a URL like: your_site/administrator/?hung123).
You also can set a Redirect URL if someones go to the URL your_site/administrator (without token). I think you should set an URL of a 404 page here.

2. Login Attempts



If you enable this function and specify Max attempts number here (e.g. 3), any user will be locked after 3 times of failed login.

3. Password Complexity

In this function, you will config for the password rule in your web site. You can select to apply on Frontend, Backend or both. This function may be useful if you use Joomla to build a social network or an intranet for your company.

Hope this plugin can help you have well sleep when running Joomla -:)

Do you have any things else? Any comment is welcome.


Thursday, January 9, 2014

Joomla: control all types of redirection and http error codes with single component

Does your Joomla website has some links (URLs) needing to redirect? You can use Redirect core component of Joomla. However, it just does 1 type 301 redirection (Moved Permanently) and doesn't support to redirect URLs with Regular Expressions.

Luckily, we have a free component which allows you control almost types of redirection and http error codes. This below inforgraphic of SEOmoz can help you understand them and how they are important in SEO.


So what is the component? It's ReDJ component. You can check out it here. The following is its features:
+Manage redirection URLs, support macros & regular expressions for URLs
+Support to define 404 page quickly
+Support to statistic http error codes which are got and their visited URLs
+Support to statistic referrer URLs

And you can use it to:
+Solve SEO problems
+Create short URLs and use them with your domain (like they are created from bitly.com)

THE END ./.

Friday, August 2, 2013

Joomla 2.5 convert utf8 string to lower case

The following function can help you convert an UTF8 string to lower case:
utf8_strtolower(string_value);

Happy coding!

Sunday, July 7, 2013

Joomla 2.5: overwrite com_search layout

As overwriting layout of any component, e.g. overwrite com_content blog layout, to customize layout of com_search, you may copy its original 2 files below:
/components/com_search/views/search/tmpl/default_form.php: display search box and search filters / conditions
/components/com_search/views/search/tmpl/default_results.php: display search results
to the html folder of your template:
/templates/your_template/html/com_search/search/default_form.php
/templates/your_template/html/com_search/search/default_results.php

Let do a sample, in which we only search in Articles and display every search result with an intro image of the article if any.

Below is an example for an article with intro image:


The following image is before this customization:

Here are the image after this customization:

To do this sample, we modify the file /modules/mod_search/tmpl/default.php of mod_search to search Articles only. Add the following line to this file:
<input type="hidden" name="areas[]" value="content" />
before line:
<input type="hidden" name="task" value="search" />

And download this file and unpack, then copy folder html/com_search to your template and plugins/search/content/content.php to joomla content search plugin.

Base on this post, you can create your search layout as you want.



Sunday, March 17, 2013

Joomla: hide backend with secret key to enhance security

If your website uses Joomla, it is easy to try login your back-end at the address: <your_website>/administrator/

Bad guys can attack your back-end with some technique, e.g. Dictionary attack.

There are many solutions to protect your back-end. Here, I suggest a way with small change in the file: administrator/index.php. Let add the following code after require_once lines:


$session =& JFactory::getSession();
$passport = $session->get('passport');
if(!$passport || $passport != "passed")
{
$goent = JRequest::getVar('your_secret_var','','get','text');
if(!$goent || $goent != "your_secret_value")
{
// Redirect to homepage
header('Location:  ../index.php');
}
else
{
$session->set('passport', 'passed');
}
}

After adding this code, you must login at: <your_website>/administrator/index.php?your_secret_var=your_secret_value

Any attempt to access <your_website>/administrator/ will redirect to your home page.

Best wishes.





Monday, December 24, 2012

Joomla 2.5: Load module by module id

This plugin will help you load a module into an article by its id.
http://www.pages-and-items.com/extensions/load-module-into-article

+Thoi Trang Tre Em

Friday, October 5, 2012

Joomla 2.5: add google gadget

A. Add to a position on the Joomla website
1. Goto Google Gadgets For Your Webpage.
2. Click "Add to your webpage" button.
3. Click "Get the code" button you will see the script to run the gadget.
4. Create a Custom HTML module on your Joomla site. Remember to clean up Prohibited Elements in Editor - TinyMCE plugin.
5. Copy and paste the code from step 3 into the source of the Custom HTML module

B. Add to an article of Joomla
1. Do same 3 steps as mentined in A
2. Copy and paste to source HTML of the article

C. Add Google sites gadget to Joomla site
1. Add the gadget to your Google sites
2. In FireFox, select the area which contains the gadget >> then right click >> View Selection Source
3. Find <iframe> tag in the source HTML and copy its content. For example, I add Google Maps gadget into my Google sites and get its iframe as the following:


<iframe class="map_embed" frameborder="0" height="500" scrolling="no" src="//maps.google.com/maps/ms?z=16&amp;ie=UTF8&amp;msa=0&amp;msid=204746671798990797697.0004a78f5b3a13d5f4a43&amp;output=embed&amp;output=embed" title="BABY &amp; KIDS FASHION" width="100%"></iframe>

4. Copy and paste to source HTML of an article or Custom HTML module

Thursday, September 13, 2012

Joomla 2.5: Where Does JToolBarHelper::custom Load Icon?

It's loaded from: administrator/templates/<selected template>/images/toolbar

For example: create a NewButton on the toolbar of your component
1. Copy ButtonIcon into administrator/templates/<selected template>/images/toolbar floder
2. Add new line to administrator/templates/<selected template>/css/template.css
.icon-32-ButtonIcon { background-image: url(../images/toolbar/icon-32-ButtonIcon.png); }
3. Declare it in your code:
JToolBarHelper::custom( 'yourtask', 'ButtonIcon.png', ' ButtonIcon .png', 'Button Name', false,  false );

Tuesday, July 24, 2012

Twitter Bootstrap Plugin for Joomla

A product from phproberto: https://github.com/digitaldisseny/plg_sys_twbootstrap

If you need to use overrides:
1. In your template create the folder
templates/YOURTEMPLATE/plg_system_twbootstrap
2. Copy the js & css folders from
plugins/system/twbootstrap
to:
templates/YOURTEMPLATE/html/plg_system_twbootstrap
3. You are done! The plugin will detect any file overriden and load it instead of plugin's default version


Joomla! 2.5: modify meta tag to guide robots


By default Joomla 2.5 does not add the robots meta tag in the header and you have no handy tool by default to do it in one place, unless you don't use some add-on which let you do this easily.

But what if you prefer to do it yourself, bare-handed, without seeing even some code? You might be surprised, but in fact in Joomla 2.5 it's very easy to set up meta tag robots for your home page and content articles.

Tweaking these settings might add you an edge over your competition in the race for better ranking in Google and Bing searches - to name only the biggest players. You can do this in two easy to follow steps:

Step 1. Go to Content >> Category Manager and open the category you need to change
Open the parameters tab "Metadata Options" and set the value of Robots for example to "noindex, follow" to prevent indexing of category blog pages, but invite search-engine bots to follow the links in the page to discover all content items linked to them.

Step 2. Go to Menus >> Menu Manager and open the menu containing the menu item to the category blog you need to change. Open the menu item, then open the parameters tab "Metadata Options" and set the value of Robots to "Index, Follow".

Done! The web bots now are properly instructed how to discover and index your site. Using these settings the category pages will have lower ranks/importance as the content pages, this way facilitating the "concentration" of Page Rank to your content pages - at least this is the SEO guys out there are claiming.

If you use still Joomla 1.5, to change the value of meta tag robots in Joomla! 1.5 for content category pages you have to add some code in your template.

// Set robots for category pages
$document =& JFactory::getDocument();
$view = JRequest::getVar('view');
if ($view == 'category') { $document->setMetaData('robots','noindex,follow'); }

Tuesday, July 17, 2012

Joomla 2.5: set session inside & get session outside


We have a need to set a session in joomla extension (e.g. component) and get (read) session in a external file  (outside joomla).

Here is the sample code:

//set session in a joomla extension
$session =& JFactory::getSession();
$session->set('asession', 'avalue');


//get session in a external file (outside joomla)

define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' )); //should change to match to your file directory
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
$session =& JFactory::getSession();
$asessionvalue = $session->get(' asession ');

Wednesday, June 20, 2012

Joomla mobile template

Some Joomla templates support mobile devices. It's the easiest way to create a mobile template for Joomla.


But if you built a template, you can use some extension to present your website on various mobile device types. Mobile Joomla might be one of the first plug-ins recommendations.

You can read this article to know more about Joomla mobile solution.

For concepts of mobile template,  read this article may be helpful for you, too.

Thursday, June 14, 2012

Joomla! 2.5: overwrite category blog layout template

Rule to overwrite a view of a component:
1. Add a copy of the component view file to the folder of your template with the following rule structure:
templates/TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php

2. After that modify it in your way.

To overwrite category blog layout (view): let copy and modify the files below:
-templates/[template name]/html/com_content/category/blog.php: present structure layout options (see meaning of Layout Options at the bottom)
-templates/[template name]/html/com_content/category/blog_item.php: present an item (article) in the blog layout

Layout Options:
# Leading Articles -> This refers to the number of articles that are to be shown to the full width
# Intro Articles -> This refers to the number of articles that are not to be shown to full width
# Columns -> This refers to the number of columns in which the articles will be shown that are identified as #Intro. If #Intro is zero this setting has no effect
# Links -> Number of articles that are to be shown as links. The number of articles should exceed #leading + #Intro

More ref:
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
http://kiteplans.info/2012/04/18/how-to-joomla-1-7-2-5-full-text-in-category-blog-layout-template-override/
http://forum.joomla.org/viewtopic.php?f=619&t=615539
http://docs.joomla.org/Understanding_Output_Overrides
http://construct-framework.com/intermediate/creating-a-core-output-override-in-construct-unified-for-joomla-16-and-molajo
http://docs.joomla.org/Layout_Overrides_in_Joomla_1.6
http://forum.joomla.org/viewtopic.php?t=677301

Tuesday, May 29, 2012

Joomla 2.5!: Classes for Accessing Database

For selecting:

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('field1,fieldn');
$query->from('#__tablename');
$db->setQuery((string)$query);
$results = $db->loadObjectList();
if ($results){
    foreach($results as $result) 
    {
        //$result->field1
        //$result->fieldn;
    }
}


For inserting:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->insert('#__tablename');
$query->set("field1='value1', fieldn='valuen'");
$db->setQuery($query);
$db->query();
To get the last insert id, use:
$db->insertid();

For udating:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__tablename');
$query->set("field1='value1', fieldn='valuen'");
$query->where("fieldx='valuex'");
$db->setQuery($query);
$db->query();

For simple query:

$db = JFactory::getDbo();
$query = "<YOUR QUERY>";
$db->setQuery($query);
$db->query();

Friday, May 18, 2012

Joomla! 2.5: Latest News Enhanced Modules

Recommend it for your website:
http://www.simplifyyourweb.com/index.php/downloads/category/14-latest-news-enhanced

Thursday, May 17, 2012

Joomla: show module title

Joomla won't show module title if your template declares display style of the module is "none" or nothing.
Check your template to CHANGE it:
<jdoc:include type="modules" name="position-name" style="none" />
TO:
<jdoc:include type="modules" name="position-name" style="xhtml" />
Subscribe to RSS Feed Follow me on Twitter!