Friday, July 1, 2016

Redirect non-www to www in .htaccess


Many customers at some point request to force either the www or non-www version of their site to display in their visitor's browser. For example always have www.example.com or simply example.com display in their visitor's web browser. There is a common thought that forcing one format is better for search engine optimization. This article will guide you through how to perform this action in your .htaccess in the cPanel for your primary domain.

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Cron Run through Wget in specific directory



If you know the name of the file ahead of time, you can use the -O option to wget to tell it where to write the file.


wget -O /public_html/vmfiles/signature/signature.php http://siteurl.com/signature.php

Friday, June 10, 2016

Php Formatting Date and Time

Php Formatting Date and Time
Day of Month
d Numeric, with leading zeros 01–31
j Numeric, without leading zeros 1–31
S The English suffix for the day of the month st, nd or th in the 1st, 2nd or 15th.
Weekday
l Full name  (lowercase 'L') Sunday – Saturday
D Three letter name Mon – Sun
Month
m Numeric, with leading zeros 01–12
n Numeric, without leading zeros 1–12
F Textual full January – December
M Textual three letters Jan - Dec
Year
Y Numeric, 4 digits Eg., 1999, 2003
y Numeric, 2 digits Eg., 99, 03
Time
a Lowercase am, pm
A Uppercase AM, PM
g Hour, 12-hour, without leading zeros 1–12
h Hour, 12-hour, with leading zeros 01–12
G Hour, 24-hour, without leading zeros 0-23
H Hour, 24-hour, with leading zeros 00-23
i Minutes, with leading zeros 00-59
s Seconds, with leading zeros 00-59
T Timezone abbreviation Eg., EST, MDT ...
Full Date/Time
c ISO 8601 2004-02-12T15:19:21+00:00
r RFC 2822 Thu, 21 Dec 2000 16:01:07 +0200
U Unix timestamp (seconds since Unix Epoch) 1455880176

Examples

Here are some examples of date format and result output.

  • F j, Y g:i a - November 6, 2010 12:50 am
  • F j, Y - November 6, 2010
  • F, Y - November, 2010
  • g:i a - 12:50 am
  • g:i:s a - 12:50:48 am
  • l, F jS, Y - Saturday, November 6th, 2010
  • M j, Y @ G:i - Nov 6, 2010 @ 0:50
  • Y/m/d \a\t g:i A - 2010/11/06 at 12:50 AM
  • Y/m/d \a\t g:ia - 2010/11/06 at 12:50am
  • Y/m/d g:i:s A - 2010/11/06 12:50:48 AM
  • Y/m/d - 2010/11/06

Friday, March 4, 2016

How to Remove Joomla's Canonical Tag


This is to clear any misconception about having a self-referenced Canonical Link Element, as using one is not an issue, and how could it be - to say that the page you are viewing at this url is actually the one you mean to display (??)

Google is perfectly fine with this. As far as I know, it only Bing that has a recommendation to avoid using self-referencing canonical urls, but even if it exists it won't make the page not indexable.

Canonical URLs is not the reason that some of your pages have not been indexed by Google. If that was true, then none of your pages should have been indexed.

Google will not guarantee that will index all the pages of a website in a given time period.

$doc = JFactory::getDocument();
 foreach ( $doc->_links as $k => $array ) {
 if ( $array['relation'] == 'canonical' ) {
 unset($doc->_links[$k]);
 }
 }

Tuesday, January 19, 2016

CodeIgniter Remove index.php By .htaccess

Steps To Remove index.php using .htaccess:-

Step:-1  Open the file config.php located in application/config path.  Find and Replace the below code in config.php  file.

//  Find the below code

$config['index_page'] = "index.php"

//  Remove index.php

$config['index_page'] = ""

Step:-2  Go to your CodeIgniter folder and create .htaccess  file.


 Path:

Your_website_folder/
application/
assets/
system/
user_guide/
.htaccess <--------- this file
index.php
license.txt

Step:-3  Write below code in .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Step:-4  In some cases the default setting for uri_protocol does not work properly. To solve this issue just open the file config.php located in application/config and then find and replace the code as:

//  Find the below code

$config['uri_protocol'] = "AUTO"

//  Replace it as

$config['uri_protocol'] = "REQUEST_URI" 

Thursday, January 14, 2016

Repeatable Form Field for Joomla

Joomla 3.2 added a nice feature introducing repeatable standard form field. Now it’s easy to add repeat fields just defined from the standard xml file of any joomla extensions. For each repeat box you can add multiple fields (joomla standard form fields ), means you can add fields under fields !

Now we will go more technical but will try our best to write it for new joomla developer.


<field name="list_templates" type="Repeatable" icon="list" description="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_DESC"
label="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_LABEL">
<fieldset hidden="true" name="list_templates_modal" repeat="true">
<field name="logoFile1" class="" type="media" default="" label="TPL_PROTOSTAR_LOGO_LABEL" description="TPL_PROTOSTAR_LOGO_DESC" />
</fieldset>
</field>

How to use two models in one view - Joomla 3


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' );
$categoriesModel->getCategories();
<?php
JLoader::import('joomla.application.component.model');
// file name, full path
JLoader::import( 'product', JPATH_ADMINISTRATOR . DS . 'components' .
 DS . 'com_virtuemart' . DS . 'models' );

$productModel = JModel::getInstance( 'Product', 'VirtueMartModel' );
?>