Just The Facts

Pages

  • Home
  • Joomla
  • PHP
  • .Net , C# & Firebird
  • Links

Wednesday, 16 December 2015

Joomla: Create Automatic Contacts with Contact Creator Plugin


Joomla allows you to automatically save new contacts in your Contact component when a user create an account.
In this tutorial we will show you how to use Contact Creator plugin to build a simple user's directory.

Enable the Contact Creator plugin

  • Go to Extensions > Plugins
  • Search for "User - Contact Creator" plugin
Contact Creator plugin joomla
  • Automatic webpage is optional
  • Select the category for new contacts
  • Set automatically publish the contact as yes
  • Set status as enable
  • Save when you’re done
Contact Creator plugin joomla

Test: register a new user

  • Go to the register area in your frontpage
  • Fill all the information such as username, email, password, etc
  • When you're done, click register button
Contact Creator plugin joomla
In your backend, go to Components > Contacts to confirm the new contact item was created automatically.
Contact Creator plugin joomla

Create a menu item

Let’s create a public page to display all the contacts
  • Go to Menus > Your menu > Add new menu item
  • In menu item type choose Contact > List contacts in a category
  • Select the category
  • Save when you're done
Contact Creator plugin joomla
Visit your public site to see the end result:
directory
 
Posted by bigmcgeek at 05:52 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla

Saturday, 12 December 2015

How to Create Tabs without Third Party Extensions for a Joomla Article

Joomla comes with native tabs support for single articles. The plugin that render this feature is the same that split an article into several pages.
In this tutorial we will show you how to add tabs in your articles with the Page break plugin.

The article

  • Go to Content > Articles > New
  • Add some content, in my example I’m using dummy text.
joomla page break plugin tabs
  • Put the mouse cursor at the beginning of the first paragraph, which later will be displayed as a tab.
  • Click Page break
joomla page break plugin tabs
  • Set a Page title
  • Add an Alias, such as some-text-with-no-spaces (optional)
  • Insert page break
joomla page break plugin tabs
Repeat the process to create a new tab. Put the mouse cursor in the end of the first set of content. For example: the second paragraph.
  • Set a title for the article
  • Save and close

The Page Break plugin

  • Go to Extensions > Plugins
  • Search “Content - Page Break”
joomla page break plugin tabs
  • Set Presentation Style as “tabs”
  • Be sure the plugin’s status is enabled
  • Save and close
joomla page break plugin tabs

The menu item

We need a link to display the article in frontend.
  • Create a menu item through Menus > Your menu > Add new menu item
  • Menu item type: Articles > Single article
  • Choose the article
  • Set a Title
  • Save and close
joomla page break plugin tabs

End result

Preview the article with tabs from the new menu item in your public site:
joomla page break plugin tabs
 
Posted by bigmcgeek at 01:03 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla

Saturday, 21 November 2015

Joomla database escape() and quote() functions

The escape() function is used to escape bad characters in order to protect against SQL injection.

The quote() function is used to quote strings, because different database dialects have different quoting characters.
So depending on the database system you use, Joomla will choose the appropriate quoting characters.
Posted by bigmcgeek at 04:40 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla, joomla component, joomla database

Friday, 20 November 2015

To add a filter to Joomla component side bar using options

To add a filter to Joomla component side bar  using options

$db   = JFactory::getDbo();
$query = 'SELECT mycolumn FROM MyTable';
$db->setQuery($query);
$rows = $db->loadObjectList();
$options = array();
foreach ($rows as $row) {
   $options[] = JHtml::_('select.option', "$row->mycolumn", JText::_($row->mycolumn));

}
JHtmlSidebar::addFilter('- Select mycolumn -','mycolumn', JHtml::_('select.options',$options,'value', 'text', $this->state->get('filter.mycolumn'), true));
Posted by bigmcgeek at 04:46 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla, joomla component

Monday, 2 November 2015

PHP- function for format file size unit

function formatSizeUnits($bytes) {
    if ($bytes >= 1073741824) {
        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
    } elseif ($bytes >= 1048576) {
        $bytes = number_format($bytes / 1048576, 2) . ' MB';
    } elseif ($bytes >= 1024) {
        $bytes = number_format($bytes / 1024, 2) . ' KB';
    } elseif ($bytes > 1) {
        $bytes = $bytes . ' bytes';
    } elseif ($bytes == 1) {
        $bytes = $bytes . ' byte';
    } else {
        $bytes = '0 bytes';
    }
    return $bytes;
}
Posted by bigmcgeek at 22:45 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: php

PHP alternative syntax for some of its control structures: if, while, for, foreach, and switch

for PHP 4, PHP 5

PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.

<?php 
if ($a == 5): ?>

A is equal to 5
<?php endif; ?>

In the above example, the HTML block "A is equal to 5" is nested within an if statement written in the alternative syntax. The HTML block would be displayed only if $a is equal to 5.

The alternative syntax applies to else and elseif as well. The following is an if structure with elseif and else in the alternative format:

<?php
if ($a == 5):
    echo 
"a equals 5";
    echo 
"...";
elseif (
$a == 6):
    echo 
"a equals 6";
    echo 
"!!!";
else:
    echo 
"a is neither 5 nor 6";
endif;

?>

Note
:  
Mixing syntaxes in the same control block is not supported.  
Posted by bigmcgeek at 04:57 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: php

Friday, 23 October 2015

Establish connection with an Amazon S3 client.using PHP

If PHP S3 client connection is not set correctly, you will get following error:
1) Error retrieving credentials from the instance profile metadata server
2) AWS HTTP error: cURL error 60: SSL certificate problem:

For S3 PHP SDK version 3, the correct connection for S3 client as follows:

 <?php
  require $_SERVER['DOCUMENT_ROOT'] . '/aws/aws-autoloader.php';
  use Aws\S3\S3Client;
  use Aws\S3\Exception\S3Exception;
  use Aws\Common\Credentials\Credentials;


//AWS access info
if (!defined('awsAccessKey')) define('awsAccessKey', 'mykey');
if (!defined('awsSecretKey')) define('awsSecretKey', 'mysecret');


$bucket = 'defashion2u';

try {
$client = S3Client::factory(array(
    'version' => 'latest',
    'region'  => 'us-east-1',
    'credentials' => array(
    'key' => awsAccessKey,
    'secret'  => awsSecretKey
  ),
    'http'    => [
        'verify' => $_SERVER['DOCUMENT_ROOT'] . '/aws/cacert.pem'
    ]
));
} catch (S3Exception $e) {
    echo $e->getMessage() . "\n";
}

?>


The parameter version, region, credentials and SSL cert must be set.
More info on the ca cert, here
Posted by bigmcgeek at 06:35 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: amazon s3, php

Monday, 12 October 2015

Free Joomla componenet to export contacts data to CSV file

Free Joomla componenet to export contacts data to CSV file.
click here for info and download
Posted by bigmcgeek at 01:15 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla, joomla component

Saturday, 10 October 2015

Reuse / Load a Model Anywhere in Joomla 2.5/3.x

Sometimes you may wish to reuse a certain function that resides in a model outside of your current scope. This helps you save time and reduce duplication. This can be achieved easily by adding the following codes.

Assuming you are trying to call a model "Categories" (/components/com_mycomponent/models/categories.php) belonging to com_mycomponent (this can be called from either within or outside of the com_mycomponent):

jimport('joomla.application.component.model');
JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_mycomponent/models');
$categoriesModel = JModelLegacy::getInstance( 'Categories', 'MyComponentModel' );

Now you can call its methods, example:

$categoriesModel->getCategories();
Posted by bigmcgeek at 03:13 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla, joomla component, joomla model

Friday, 9 October 2015

PHP Essential Quick Reference

PHP essentials

25 Essential PHP Functions
Posted by bigmcgeek at 22:13 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: php

PHP - Inserts HTML line breaks before all newlines in a string

(PHP 4, PHP 5)
nl2br — Inserts HTML line breaks before all newlines in a string

Description string nl2br ( string $string [, bool $is_xhtml = true ] )
Returns string with '<br />' or '<br>' inserted before all newlines (\r\n, \n\r, \n and \r).

Parameters
string
The input string.

is_xhtml
Whether to use XHTML compatible line breaks or not.

Return Values
Returns the altered string.

Examples
Example #1 Using nl2br()
<?phpecho nl2br("foo isn't\n bar");?>

The above example will output:
foo isn't<br />
 bar

Example #2 Generating valid HTML markup using the is_xhtml parameter
<?phpecho nl2br("Welcome\r\nThis is my HTML document", false);?>
The above example will output:

Welcome<br>
This is my HTML document


Posted by bigmcgeek at 22:01 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: php

Multiple controllers in Joomla MVC component

Joomla basic tutorial and understand that the main controller is located under components/com_component/controller.php & other file is components/com_helloworld/helloworld.php which is pointing to controller.php file to execute the request. You create new controller folder and put all controllers in that folder


The main controller is typically used to do what you mention in your comment (render a view based on the view parameter, usually specified in the URL). In controller.php, the function that does this is called display(). So the following URL:

http://example.com/index.php?option=com_mycomponent&view=test

Will result in calling the display() function in controller.php and loads the view test in /views/test.

Subcontrollers, in the controllers folder, are generally used for CRUD tasks, but can be called easily by using a task URL parameter. For example:

http://example.com/index.php?option=com_mycomponent&task=test.process

Will result in calling the process() function in /controllers/test.php - notice the task parameter is <controllerName>.<functionName>
Posted by bigmcgeek at 19:18 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla, joomla component

How to switch the ‘action’ field in an HTML form dynamically

It is often required that you need to send the data in the same form to different server-side scripts depending one certain criteria. JavaScript allows you to modify the action field of an HTML form dynamically.
 

Multiple submit buttons

It is possible to have more than one submit button in a form. The example below shows how to switch the action field based on the submit button pressed.
 
<script type="text/javascript">
function OnSubmitForm()
{
  if(document.pressed == 'Insert')
  {
   document.myform.action ="insert.html";
  }
  else
  if(document.pressed == 'Update')
  {
    document.myform.action ="update.html";
  }
  return true;
}
</script>

<form name="myform" onsubmit="return onsubmitform();">
 
<input type="submit" name="operation" onclick="document.pressed=this.value" value="insert" />
 
<input type="submit" name="operation" onclick="document.pressed=this.value" value="update" />
 
</form>
 
 

Based on a radio button

The example below shows a case where the action field is switched based on the selection in the radio buttons.


<script type="text/javascript">
function OnSubmitForm()
{
  if(document.myform.operation[0].checked == true)
  {
    document.myform.action ="insert.html";
  }
  else
  if(document.myform.operation[1].checked == true)
  {
    document.myform.action ="update.html";
  }
  return true;
}
</script>
<form name="myform" onsubmit="return OnSubmitForm();">
   name: <input type="text" name="name"><br>
   email: <input type="text" name="email"><br>
   <input type="radio" name="operation" value="1" checked>insert
   <input type="radio" name="operation" value="2">update
   <p>
   <input type="submit" name="submit" value="save">
   </p>
</form>

Posted by bigmcgeek at 18:53 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: html, javascript

Joomla Useful reference

Joomla Constant
https://docs.joomla.org/Constants


Component
Developing Joomla 3.x component
Posted by bigmcgeek at 04:12 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: joomla
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Advertisement

Popular Posts

  • Opportunistic Locking & SMB2
    What is Opportunistic Locking? Opportunistic locking (oplocks) is a Windows-specific mechanism for client/server databases to allow multip...
  • c# - TextFieldParser
    using Microsoft.VisualBasic.FileIO; string csv = "2,1016,7/31/2008 14:22,Geoff Dalgas,6/5/2011 22:21,http://stackoverflow.com,\"...
  • Network discovery stays off in Windows Server 2012
    In order to enable the Network Discovery on a domain make sure the following services are enabled and running: DNS Client Function Discove...
  • How the PCB for bonus is calculated
    The Potongan Cukai Bulanan (PCB, a.k.a. Scheduled Monthly Tax Deduction) calculation for bonus is not so straight forward. Here is how it ...
  • Firebird - Context variables
    ----------------------------------------- Generic user and system context variables ----------------------------------------- for firebir...
  • Beginner’s Tutorial on Using the Firebird ADO.NET Client 2.5
    http://www.codeproject.com/Articles/33675/Beginner-s-Tutorial-on-Using-the-Firebird-ADO-NET
  • SourceGrid - Open Source C# Grid Control
    http://www.codeproject.com/Articles/3531/SourceGrid-Open-Source-C-Grid-Control
  • InnoSetup Dependency Installer
    http://www.codeproject.com/Articles/20868/NET-Framework-1-1-2-0-3-5-Installer-for-InnoSetup
  • Validating Properties In A .Net Propertygrid Control
    The easiest way to validate a certain property in a .Net propertygrid control is using the PropertyValueChanged event.The code bellow shows...
  • To remove the font size, search box & space above the header in joomla 2.5
    To remove the font size, search box & space above the header in which they preside in the Beez 20 template there are 2 steps. All you mu...

Followers

Blog Archive

  • ▼  2015 (14)
    • ▼  December (2)
      • Joomla: Create Automatic Contacts with Contact Cre...
      • How to Create Tabs without Third Party Extensions ...
    • ►  November (4)
      • Joomla database escape() and quote() functions
      • To add a filter to Joomla component side bar usin...
      • PHP- function for format file size unit
      • PHP alternative syntax for some of its control st...
    • ►  October (8)
      • Establish connection with an Amazon S3 client.usin...
      • Free Joomla componenet to export contacts data to ...
      • Reuse / Load a Model Anywhere in Joomla 2.5/3.x
      • PHP Essential Quick Reference
      • PHP - Inserts HTML line breaks before all newlines...
      • Multiple controllers in Joomla MVC component
      • How to switch the ‘action’ field in an HTML form d...
      • Joomla Useful reference
  • ►  2013 (10)
    • ►  September (1)
    • ►  June (6)
    • ►  May (1)
    • ►  April (1)
    • ►  March (1)
  • ►  2012 (49)
    • ►  November (6)
    • ►  October (7)
    • ►  September (3)
    • ►  August (5)
    • ►  July (2)
    • ►  June (7)
    • ►  May (3)
    • ►  April (10)
    • ►  March (2)
    • ►  February (3)
    • ►  January (1)

Labels

  • .Net
  • amazon s3
  • android
  • bonus pcb
  • business
  • button
  • C#
  • css
  • css print
  • File System
  • firebird
  • gimp
  • html
  • iis
  • image
  • income tax
  • innoSetup
  • investment
  • ipad
  • iphone
  • java
  • javascript
  • joomla
  • joomla component
  • joomla database
  • joomla model
  • jquery
  • large photo
  • mobile phone
  • mssql
  • ODBC
  • open source
  • Opportunistic Locking
  • passport
  • passport renewal
  • pcb
  • php
  • PropertyGrid
  • remote app
  • slideshow
  • smartphone
  • SMB
  • SMB2
  • web
  • web browser
  • windows 8
  • Windows form
  • windows server
  • Xml

About Me

bigmcgeek
Knowledge, Information and Useful tips
View my complete profile

Advertisement

Simple theme. Powered by Blogger.