You are browsing the archive for html.

PyroCMS Widget Creation for Affiliate Marketing – Section 1

8:51 AM in CSS, Frameworks, jQuery, PHP, Programming, PyroCMS by Vic Russell


PyroCMS is a very powerful and capable PHP-based CMS.  It is authored on top of the Codeigniter framework.  It is very fast, and scalable and very promising as a powerful PHP framework.

Download the affiliate.zip file here

Caveat: The documentation for PyroCMS (PCMS) is very sparse.  Any answer to any question can be exceedingly  difficult to find.  Check back often for additional links to developing documentation.

One of the new and useful features of PyroCMS is the addition of Widgets.  Now, we all know what a widget is, right?  Actually, in the PCMS world, the concept of widget is very accurate – it is a discrete entity (in this case, a class) that can be added to a page, section of a page (right sidebar, left sidebar, header, footer, content, etc) that can access the database as well as execute custom code and present content that you create, in a format you define. You can use this to display images, text, and any other content you decide is needed – EXCEPT for JavaScript.

Let me clarify the javascript problem: if you want to create a widget that allows you to enter javascript snippets, it will not work – the <script> tags as well as any document.write() methods are stripped out for security reasons and replaced with [removed].  I am searching for a workaround, but given the above statement regarding documentation, this might take some time.  [ note: The feature within the Codeigniter (CI) form_helper class that sanitizes strings is xss_clean and prep_for_form ]. Until then, I am adding the needed JavaScript in the class and view files.

There are adequate installation documentation and install examples on the web for installing PyroCMS and Codeigniter.  Here are a couple.

PyroCMS Installation

Installing Codeigniter (this is link is provided only for reference - you do not need to download and install CI as PyroCMS is built on top of CI)

It is critical that you define your database connection accurately, and remember your default user name and password.

Our Platform

I am using a Dell laptop with 2 GB of RAM and a dual core Athlon X2 processor (circa 2006) with WAMP (Windows Apache MySQL PHP) installed for development, PHP Designer 7 as the IDE (Eclipse is too heavy, but would work with a more powerful machine).  WAMP is a very easy install.

All of my web files are under C:\wamp\www\ - which is the default web root for a typical WAMP installation.

Lets create a widget in PyroCMS - 'affiliate'

There is no widget named affiliate that comes with your installation.  Therefore, any reference to a file or folder/directory implies you have added it or should add it.

Navigate to the widgets directory under the application directory

  • (note: I am a Linux developer first - some of my paths will have the forward Unix-style slash ( / ) rather than the backwards Windows-style slash ( \ ).  Make adjustments where needed if I forget to use Windows style slashes)

C:\wamp\www\pyrocms_directory\application\widgets\affiliate

First, create the directory within the ...\widgets\ path called affiliate.

PyroCMS Widget Directory Structure - randaweb

Widget Directory Structure

Copy the code from this link into a download folder, extract the files, then copy the the files into the above path.  You will copy the 'views' directory and the affiliate.php file into the affiliate directory (see folder screenshot).

Download the affiliate.zip file here

Within the 'views' directory, you will have two files:  display.php and form.php. These files, and the containing 'views' folder, will be  present in every PyroCMS widget you create - these files are required and necessary.

  • The first file you edit (or create, depending on your need) is the class file.  Remember to capitalize the name of the class - which must be the same name as the file (less the .php extension :-) ).

Here is a bare affiliate.php file after editing to add the fields needed for the new widget:

<?php
if(!defined('BASEPATH')) exit('No direct script access permitted');
class Affiliate extends Widgets
{
// This section will appear when you click on the widget on the 'widgets' page of the admin
// interface (aka dashboard).  You access the admin interface using the following URL:
// http://your-host/your-pyrocms-base-dir/admin
public $title = 'Affiliate Widget';
public $description = 'Add Affiliate Links and Images';
public $author = 'Vic Russell';
public $website = 'http://www.randaweb.com';
public $version = '0.3';
// Now you define the fields that you will use in your widget.
// The widgets class will contain a 'name' field, so it is optional here
public $fields = array(
array(
'field' => 'aff_title',
'label' => 'Product Title',
'rules' => 'trim|max_length[254]'
),
array(
'field' => 'aff_order',
'label' => 'Add Order - 1 = new line',
'rules' => 'trim|max_length[3]|integer'
),
array(
'field' => 'aff_link',
'label' => 'Affiliate Link',
'rules' => 'required|trim'
),
array(
'field' => 'aff_alt',
'label' => 'Affiliate Alt Text',
'rules' => 'trim|prep_url|max_length[254]'
),
array(
'field' => 'aff_class',
'label' => 'CSS Class',
'rules' => 'trim|max_length[254]'
),
array(
'field' => 'aff_style',
'label' => 'CSS Style',
'rules' => 'trim'
),
array(
'field' => 'aff_source',
'label' => 'Affiliate Source)',
'rules' => 'trim|max_length[254]'
),
array(
'field' => 'aff_company',
'label' => 'Company Source for add',
'rules' => 'trim|max_length[254]'
)
);
public function run($options)
{
// The requisite 'run()' method that returns the data in the $output[] array //
if(empty($options['aff_title']))
{
return array('output' => '');
}
return array('output' => array($options['aff_title'], $options['aff_link'],
$options['aff_alt'], $options['aff_class'], $options['aff_style'],
$options['aff_source'], $options['aff_company'] ) );
}
}
/* Close class Affiliate */






New Domain – jqueryform.info

2:43 PM in jQuery, Programming by Vic Russell

jqueryform.info is a domain I just purchased to use for dedicated jQuery forms blogging.  The jQuery ‘forms’ topic is huge, as anyone who uses jQuery knows.

Sample topics:

  • validation (client and server side handling/callbacks/etc)
  • AJAXifying forms
  • processing select, checkbox, and radio button tags
  • presenting error information elegantly
  • Myriad of plugings related to forms and form processing

I am going to try GoDaddy for hosting this site round.  I am not being critical of Hostmonster, I just have to test another hosting solution before I pony-up for a dedicated server or VM.

If anyone has a suggestion re: a hosting provider – and I mean direct experience – feel free to reply to this post. Please include the reason(s) why you like or do not like the provider – submissions with only a link and sales text will be removed.

Til Tomorrow…

Vic.

Web Design and Development Links

2:18 PM in Programming by vrussell

Links to very interesting and useful sites that will help inspire, teach, and inform.

Design:

Smashing Magazine – User Interface concepts:  http://www.smashingmagazine.com/

Zen Garden – examples of how CSS can be beautiful:  http://www.csszengarden.com/

Design and Development:

SitePoint - amazing JavaScript and CSS references : http://www.sitepoint.com/

Read the rest of this entry →