phpyellowtm developer guide

Start | Customize | Payment | Questions

Customize

This page contains information or links to the following:

Changing Open Source Code

phpYellow has unencrypted open source code written in text format. You may change the code to suit yourself (subject to the license). When changing open source code:

  1. make a backup file first so you may always restore the most recent working code
  2. use a non-invasive HTML editor

Non-invasive HTML editors

A few popular HTML editors - which previously included Microsoft Frontpage and Macromedia Dreamweaver - changed the source code on every page loaded. The change could be minimal, for example adding line breaks, non-breaking spaces or non visible output. However the result of an invasive change can be and frequently is the failure of php scripts to run. If your scripts fail to work then this is an issue. The solution is to use a non-invasive HTML editor - or to use the options within your editor to turn non-invasive mode on.

example: a common issue maker is to edit the util.php file for your needs, then to save and upload the file. Unfortunately, this frequently results in multiple warnings about failed session handling because the editor has introduced unnecessary characters into the source code. The solution is to open a fresh, unused copy of util.php in non invasive mode.

What HTML editor can be used?

Download Edit Plus For Windows operating system, you may use Edit Plus from http://www.editplus.com. Download (free edition available) install > click File New > HTML page. Click on the magnifying glass to preview the page, and click same location again to get the source code. Edit Plus is clean, powerful and has good learning features.

You may also browse http://www.download.com and find other good html editors.

Constants

To customize the constants on util.php will make the most initial dramatic change to your directory. Constants like YOURPHPYELLOWNAME, your BENEFIT and other highly visible data may be changed in util.php

CSS - Cascasding Style sheet - yellow.css

Make directory wide changes to html tags using a css editor like TopStyle. Tags like <h1>, <p>, <ul>, <table>, <td> and many others are easily changed across all pages using just a css editor and just one main file - yellow.css. You may also create your own .class styles. A Netscape .css file is also included and will be offered to Netscape users. Expect over 80% of your visitors to view your pages in a recent Internet Explorer browser.

Front page

It is common to customize the front page. Open up index.php and modify to suit. Make sure your editor opens php files in "non-invasive" mode. Any other mode may change your php code and cause the application to fail. In such cases the normal remedy is to replace the file and start afresh.

Search Type

Browse search.php to see available search types. At last count there were six different searches you could use in the Pro Edition.

Search Default

The default search is set in util.php

define("DEFAULT_SEARCH", "browse");

DEFAULT_SEARCH is displayed on the frontpage named index.php and also at the bottom of search results.

Combine two or more search types

You may also build your own search default by combining two or more search types. Open searchDefault.php in an editor to view more help about changing the default search. Refer back to the search.php page for examples.

Change the data shown

When search results are shown certain data is shown. You can change the data shown.

  • Pro Edition - edit proListing*.php
  • Lite Edition - edit oneRecord.php

Edit proListing*.php

All data in the database is available. You decide what data to display by modifying the look and feel of these files:
  • proListingBasic.php
  • proListingFeatured.php
  • proListingPremium.php
  • proListingSponsor.php
  • proListingOneLine.php
The default data displayed corresponds to the Listing Type descriptions found in the Client Control panel. If you materially change the default data shown then also change ListingTypeDescriptions.php to reflect your new default data.

Following are the variable names to use when changing the data shown:

Variable Explanation
$yfps same as customerid
$yfpassword password
$yfemail email - do not display email. phpYellow looks up the email based on the customerid. Email is never shown, and should not be shown, to safeguard the interests of the customer.
$yfcompany organization
$yffirstname firstname
$yflastname lastname
$yfaddress address
$yfcity city
$yfstateprov subjurisdiction. Example: United States states, or Australian states, or Canadian Provinces, or Hawaiian islands
$yfcountry nation
$yfpostalcode zip or postal code
$yfareacode phone area code
$yfphone telephone number
$yffax fax number
$yfcell cellular telephone number
$yfurl website
$yflogo organization logo
  customersince - not yet used
  visits - not yet used
$yfrole role, title or other designation
$yfprivacy privacy
$yfnews news
  newsformat - not yet used
$yflastupdate timestamp of last database update
$yfckey unique category table primary key
$yffkcustomerid unique category table relational key. This is the same as $customerid
$yfcategory category
$yfdescription description
$yfrank rank of the listing.
$yfpaymentrequired not yet actively used by the program
$yfstatus approved, pending or expired
$yfexpires date listing expires on
$yflastupdate date of last table record update timestamp
$yfimage2 product or service image. Note, the file is actually stored in /userlogo.
$yfimage3 product or service image.
Variable Explanation


Example: to display the firstname and lastname fields:

<?php echo $yffirstname . " " . $yflastname; // displays firstname, a space, and lastname ?>

Change the structure of the page layout

phpYellow is designed with a "sandwich" structural page layout like this: Sandwich structure

Some customers want a "horseshoe" structure like this: horseshoe structure

Modified files - new.php and yellowresult.php (with left.php and right.php) demonstrate how to achieve the 'horseshoe' structure. Following are details:

new.php
new.php is the template for how most pages will look. Of note, it contains a header.php, left.php and right.php . Build your other pages based on the structure of new.php

yellowresult.php
yellowresult.php has been modified such that it contains header.php, left.php, the search results, right.php and footer.php . This change was only done for one module, the 'Browse' module. You will need to update the 'Advanced Search' module to display the structural layout of 'Browse'.

HOW TO DEPLOY

  1. Backup yellowresult.php, footer.php, header.php and new.php
  2. locate the files in phpyellow/structure (or request files here)
  3. copy all /phpyellow/structure files into your /phpyellow folder
  4. test the browse and new.php pages
  5. modify left.php and right.php
  6. test
  7. apply to other pages

There is still work required of you in order to modify the structure. Hopefully the available files will make it easier.

Miscellaneous

Following are miscellaneous notes about customization:

How to change the default rank of all new listings

The default rank for listings added to your directory is the number 0. To make all new listings start at a higher rank change the rank. You may do so by pasting this code into EasySQL as accessed from the Administration Center:

ALTER TABLE pycategory CHANGE rank rank TINYINT(1) UNSIGNED NOT NULL DEFAULT 1
Use a higher number to set a higher default. Acceptable range is 0 through 2.

Files Likely to Need Cosmetic Change

These are some of the files you may change to effect the look and feel you want:

  1. header.php - modify to suit
  2. footer.php - modify to suit - *** a link is required ***
  3. yellow.css - modify to suit using a .css editor like Topstyle from http://www.bradsoft.com
  4. oneRecord.php - do not change. This file is the central template for how one record looks like to the users, for the Lite Edition.
  5. categories.php - modify to suit. Add your very own categories!

Change the Look and Feel of each Record

Pro Edition

phpYellow Pages is capable of showing any combination of data [database fields] you wish. If the data is contained within the database, then the data may be displayed in a record.

Display Type

With phpYellow Pages version 2.32 or higher you may choose to offer:
  • RESULTS_ON_ONE_LINE and Complete display or
  • Complete display only

RESULTS_ON_ONE_LINE is useful for displaying a large number of records. A few features of each record are shown on one line, with a link to complete record detail.

Complete display only is useful for a smaller total recordset - where the visitor is not overwhelmed with listings. Example: a small specialized directory. Note that the 'Search using Like' form is designed to let your visitors choose between Complete and One Line results.

Turn Off RESULTS_ON_ONE_LINE

If you do not wish to offer RESULTS_ON_ONE_LINE - you only want to offer Complete detail - then:

  1. open util.php, save as utilBACKUP.php, and close this file
  2. open util.php, find the constant called "RESULTS_ON_ONE_LINE"
  3. change the constant value from "yes" to "", save and upload to your server
The result of your change will look like this:

define ("RESULTS_ON_ONE_LINE", "" ); // no value exists between the double quotes, it is empty.

Add, remove or modify the data shown with RESULTS_ON_ONE_LINE

To change WHAT data [database fields] are displayed with RESULTS_ON_ONE_LINE:
  1. open proListingOneLine.php, save as proListingOneLineBACKUP.php, and close this file
  2. open proListingFirstPage.php as a reference for variables you may use
  3. open proListingOneLine.php
  4. add, remove or modify any variable [database field] you wish in proListingOneLine.php. Possible choices of fields to modify or add are contained within proListingFirstPage.php
  5. save and upload to your server

Change Data Shown with Complete Record Display

phpYellow Pages can show different data based on the rank of any listing. Default display is provided for the various ranks. Login and refer to the phpyellow Client Control Panel for a description of the listing types.

showOneRecord.php controls listing templates for each listing type.

Lite Edition

The Lite Edition does not recognize and does not use ranks for listings in searches. Accordingly, one file is used to show results for user initiated searches - oneRecord.php. This file can be modified to suit your taste. Using plain HTML or php you can show data or rearrange the look, or change color or font-size or font-family ... basically any change you want to make.

Preferred Customization Methods

It is preferable to make as many changes as possible using an external .css style sheet. By making changes to the external style sheet you keep your content separate from the formatting (font, color, position and so on...). This in turn allows you to:

  1. easily make sitewide changes with just one file
  2. easily upgrade to a pro edition of phpYellow Pages
  3. easily upgrade to a newer version of phpYellow Pages

The more changes you make to the original php files the more work you are creating for yourself in the long term. Do yourself a favor and keep the content separate from the formatting - by learning how to use cascading style sheets. The Web Developer's Virtual Library has excellent resources for you to learn CSS styles.

Using Images

Images are used in the Pro Edition only. Image use and operation may also be changed by the phpyellow site administrator. The following descriptions are for any phpyellow Pro Edition 3.x or higher, and are based on default settings.

Three images may be shown with any one listing. The company logo, and two product or service images.

COMPANY LOGO

One image is called the 'company logo' and is associated with the company. Anytime the company information is displayed the 'company logo' can be displayed, if the logo is uploaded by the user and if the phpyellow site administrator has allowed logos in util.php configuration.

By default the logo will NOT be displayed in results unless paid for, although the administrator has the capability to change this logic.

Restrictions on dimension and file size The administrator may place and modify the built in restrictions on dimension of the logo, and total file size uploaded, by modifying util.php

TWO PRODUCT OR SERVICE IMAGES

In addition to the logo, two product or service images - category images - may be shown. These images are associated with a specific ckey #. The images are shown only when the related category listing is shown. There are no restrictions on dimension or file size for these images.

HOW TO CHANGE PLACEMENT OF IMAGES

The placement of an image - where it appears on the listing - may be changed by modifying the file which displays it. Change one or all of:

a) proListingBasic.php // by default this does NOT show any images
b) proListingFeatured.php // shows 'TopPick' image c) proListingPremium.php // shows logo and category images
d) proListingSponsor.php // shows logo and category images

You may move the location of - or entirely remove the logo or images - from these pages.

W3C Cascading Style Sheets

phpYellow Pages is compliant with the W3C's HTML 4.0, which since 1997 has been recommending that you keep structure apart from formatting. For example, in a Heading 1 tag colored red, the heading tags will be in the html document, and the color for the heading will be in an external .css file. This makes it easy to make sitewide changes in formatting to every page, but at the cost of a learning curve for .css - well worth it! You may find .css tutorials online and contained within better html editors.

Netscape Display Optimization

Netscape users will be familiar with display dysfunctionality in Netscape, especially in regard to W3C cascading style sheets. Netscape 6 (and higher versions) do a tolerable job in supporting Level 1 CSS. Most (if not all) of phpYellow Pages only uses CSS Level 1, and most phpYellow Pages should display tolerably well in Netscape 6 or higher.

How to Optimize for Other Netscape Browsers

The formatting for phpYellow Pages is driven with external cascading style sheets. There is also browser detection. When a user loads any page a javascript detects their browser and loads a .css file for that specific browser make. To change the look and feel for Netscape simply open netscape.css in any css editor and format this file to suit your tastes. You can have a totally different look and feel for Netscape visitors - and another for Internet Explorer visitors.

You can add more browser types by adding another case statement block and a related css file in the yellow.js script. Based on an analysis of website traffic most surfers use recent browser versions. You can add specific versioning if you want but the traffic that will use it will tend to be negligible.

Use Your Own Categories

One of the ways to customize phpYellow is to make changes to the category values. For example, instead of offering a generic Yellow Page service, you may change all the category values to the type of service you wish to have an online directory for. You may want to build a directory just for Real Estate services in your city, or create a Tourism only directory, or a High Tech services directory for your state, or an Automobile Dealer directory in your country, or ... the potential is limited only by your imagination. To make such a change will dramatically specialize your phpYellow implementation and very possibly enable you to provide a UNIQUE service not offered elsewhere.

Specialized directories can be created by using the categories*.php files as found in the distribution package. To do so, change the filename containing the categories you want to "categories.php".

How to Change an Individual Category

It's easy to customize the categories of products and services in phpYellow. Open up the file named categories.php in your html editor. Add, edit or remove one or more categories like this:

Example

Replace each select list item with the value and value displayed to the user that you want. For example, within categories.php:

<option value="Air-Conditioning">Air Conditioning</option>

Above you may change the actual value of "Air-Conditioning" to, for example, "Education". Also remember to change the words between the begin and end of the <option> tags to "Education". The value= contains the data which gets posted to the database. The other identical category word is what the user actually sees when they view the drop down list.

Upload the new categories.php file to your web server and that's all you need to do - if these changes are made before you go online with your phpYellow implementation.

In NO CIRCUMSTANCE should you change any php or selected code or variables when making these category option changes. Change the option values only. By making these changes you are merely altering the V A L U E S that get selected by the user and sent or searched from the database. Instead of storing generic Yellow page like values, you are storing specialized values for your particular implementation - for example all services and products relating to "Education", or "Internet Products and Services" - whatever your implementation is. Changing the values makes all the difference - everything else still works exactly the same way - it is the values that make the results different. Any developer can make these value changes by following the steps detailed above.

Changing the categories within Administration

In Pro version 2.22 and higher you may change the category of a listing using a point and click tool. This tool is called 'Set CKEY Parameters'. The listing expiry date, category, position, payment required and status may be changed. A pop up window reports the result of your selection and automatically closes in POPUPTIMEOUT milliseconds. You may set your own value for POPUPTIMEOUT in the util.php file.

Change the category of a listing using a point and click tool

For example, you can change a category submitted by the user for their listing from "Computer Software" to "Internet Products". To do so you need to note the ckey number stamped on the listing (obtained via any search), then use the number in the 'Set CKEY Parameters' admin tool as pictured above.

How to Customize SUBJURISDICTION

	This feature lets you quickly identify and customize sub-regions
	within your own country.

	define("SUBJURISDICTION", "world"); /* modify - 'world', 'USACanada', 'USA', 'UK', 'Canada'

	Determines the type of country subregion: open entry text box, a state list, 
	the UK county list, Canadian provinces or ... add your own case.

	The result is shown in various forms that use such data. If you _add_ a 
	new subjurisdiction please forward the sj*.php code to us for 
	free inclusion in the next release. To change the existing SUBJURISDICTION 
	open util.php and enter your preferred value. Example: 'world', 'USACanada', 'USA', 'UK', 'Canada' 
	or others as shown to be available.
	

How to Customize Your Countries

Changing provinces or countries is similar to changing categories. Open up the provinces or countries file, make desired changes, save and upload to your web server.

Modify the data fields you want to make required

The bare minimum requirements for any listing is email and password. If you want to make MORE data fields required then follow these steps:

HOW TO MAKE DATA REQUIRED

To require certain data to be entered by the user:

  1. save yellow.js as yellowORIGINAL.js
  2. open yellow.js in your html editor
  3. identify the js function to be changed
  4. find the data to require: example: locate the // Phone section
  5. make changes
  6. save yellow.js and upload to your web server
  7. test by adding and editing a new record
  8. [OPTIONAL] color code [red] the new fields you require

Detail - Link a URL to a specific Database Record

You can build a link to point toward a specific record. The "Detail" feature is used to do so. "Detail" selects a specific record number using the form:

http://www.yourDomain.com/phpyellow/yellowresult.php?goal=Detail&ckey=1

Change ckey to the value of your record. ckey may be located by completing any search and looking for " On correspondence quote ckey# ". By default this is found in each displayed listing. You may also find it by asking the webmaster. ckey is the unique database key for the category record. For example, when you submit a listing you have a single contact table record number, called customerid. When you submit one or more category records each record has a unique number called ckey. The two tables are joined together as needed using a common id. A special script is programmed to find the ckey and display the related contact and category record on a page all by itself.

How to set a specific expiration date for any listing

A specific expiration date can be set by:

  1. find the ckey number of the listing to change. Example: ckey = 1234
  2. convert your expiration date into a format accepted by the database

    Example
    i) customer has paid for more time and the remaining and new listing duration adds up to a new expiration date of Wednesday, June 25, 2004
    ii) database format required is: YYYY-MM-DD
    iii) new date is: 2004-06-25


  3. login to administration
  4. launch EasySQL
  5. paste this query into the textarea box:

    UPDATE pycategory SET expires='$newDate' WHERE ckey='$ckey'

  6. replace $newDate and $ckey with the real values
  7. click on 'Run My Query'


Start | Customize | Payment | Questions