The Techjoomla Blog

Stay updated with all the latest happenings at Techjoomla. From news about the developments in your favourite extensions to Tips & Tricks about the Joomla CMS, Framework & Development.

Posted by on in Joomla Development
How to access Joomla plugin parameters anywhere inside Joomla code?

When developing a new Joomla extension or making changes to existing extension, you might need to access plugin parameters of a Joomla plugin outside the plugin code. There can be cases where you want to access plugin parameters in some Joomla module or component. Now the question is - How to get plugin parameters outside the plugin code?

b2ap3_thumbnail_access-joomla-plugin-params.png

Here is a snippet of a Joomla code in PHP that let's you access plugin parameters anywhere inside Joomla.

// Get plugin 'my_plugin' of plugin type 'my_plugin_type'
$plugin = JPluginHelper::getPlugin('my_plugin_type', 'my_plugin');

// Check if plugin is enabled
if ($plugin)
{
	// Get plugin params
	$pluginParams = new JRegistry($plugin->params);

	$param1 = $pluginParams->get('param1');
	$param2 = $pluginParams->get('param2');
	$param3 = $pluginParams->get('param3');
}

 

Wasn’t that easy?
I hope this helps! Thanks for reading!
Feel free to add your comments.

 

Hits: 232 Comments
Rate this blog entry:

Posted by on in Joomla Development
Our experiments with quality

Last year was quite fruitful for us in terms of setting up several systems and processes to make sure our releases are more sharp and our code is much better. After several great suggestions and some oops! moments, we decided to pull up our socks and kicked off the slow but disciplined process of code review and infusing good quality into our products and projects. These are experiments and we are of course measuring what works best and will continue to tweak our quality process to further strengthen it

We've taken some great steps and implemented several automated checks which will reject bad code. We also thought of sharing them with everyone so everyone can benefit. Here's a list of things that are already implemented or are in the process of being implemented

Continue reading
Hits: 345 Comments
Rate this blog entry:

Posted by on in Joomla Development
Location tracking made easy with Google Maps APIs

Hey Guys,

We come across situations where locating a place becomes imperative; whether it's a venue for an event, site office or anything. Just to make sure that this  problem is overcomed, you need to add google maps support in your extensions, website and applications wherever necessary. This can be achieved with the help of certain information like the IP addess, Latitudes and Longitudes.

In this blog we are going to see how to use  Google maps APIs to show map (based on location)

 

Continue reading
Tagged in: Subscriber Connect
Hits: 2699 Comments
Rate this blog entry:

Posted by on in Joomla Development
Adding a parameter to Joomla component's menu item is as easy as pie!

Hey Guys,
In this blog we are going to see how to add a parameter to a Joomla component's menu item. This parameter can be used while referring view level in Joomla 2.5.x or 3.x.
Following are the steps to achieve this.

Step 1:

You have to specify parameter / option in your_layout.xml file in your component.
Lets say, you have to add “pageLimit” parameter to default layout of a view named 'products'. For menu item, you have to create add default.xml for this layout and have to add parameter entry as given below.

a. Add a xml file at location

site/components/com_yourcomponent/views/products/tmpl/default.xml

b. Add following code in above xml file

<?xml version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="All Products View" option="View" >
		 <message><![CDATA[Quick2Cart All Products View]]></message>
	</layout>

	<!-- Add fields to the parameters object for the layout. -->
	<fields name="params">
		<fieldset name="advanced" label="COM_MENUS_LAYOUT_FEATURED_OPTIONS">
			<field name="pageLimit" type="text" default="20" label="Product Limit" description="Limit to display product on All products view" />
		</fieldset>
	</fields>

	<state>
		<name>All Products</name>
		<description>All Products View </description>
	</state>
</metadata>

After adding the file, this parameter will be displayed while creating menu item for products view. Refer the following screen-shot for this.

...
Continue reading
Hits: 3056 Comments
Rate this blog entry:

Posted by on in Joomla Development
Adding validation in Joomla for post_max_size and memory_limit

Hey Guys,

In this blog we will see how to handle validation for ‘post_max_size’ and 'memory_limit' in Joomla for file uploads. Sometimes when dealing with file uploads in Joomla or in any PHP frameworks, form post size can exceed the max allowed ‘post_max_size’ (set in php.ini in your server configuration). If the size of post data exceeds post_max_size, the $_POST and $_FILES superglobals are emptied. Now, if post size validation is not added, it becomes very difficult for the end user as well as developer to track what exactly the issue is.

Using the code given below for 'post_max_size' and 'memory_limit' validation we can display the warning if post data is greater than ‘post_max_size’ or if the 'memory_limit' is exceeded in the same way as ‘com_media’ in Joomla does.

Let's Code:

// Total length of post back data in bytes.
$contentLength = (int) $_SERVER['CONTENT_LENGTH'];

// Maximum allowed size of post back data in MB.
$postMaxSize = (int) ini_get('post_max_size');

// Maximum allowed size of script execution in MB.
$memoryLimit = (int) ini_get('memory_limit');

// Check for the total size of post back data.
if (($postMaxSize > 0 && $contentLength > $postMaxSize * 1024 * 1024) || ($memoryLimit != -1 && $contentLength > $memoryLimit * 1024 * 1024))
{
	// Show warning and return
	JError::raiseWarning(100, “Total size of upload exceeds the limit.”);
	return false;
}

  

b2ap3_thumbnail_oie_815511jDoPNs0N_20141009-060335_1.pngHope this helps! :)

...
Continue reading
Hits: 2561 Comments
Rate this blog entry: