Community @ The Turning Gate

Support community for TTG plugins and products.

You are not logged in.

#1 2015-05-02 12:47:36

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 12,662
Website

tips for using phplugins

When using phplugins there are a couple of "gotchas" that might just get you.

The first is if you use a word processesor instead of a plain text editor to edit the phplugins.php file. Word processor text formatting can make bad things happen to good code.
There are some great, free, syntax-highlighting text editors available.
For Windows, try Notepad++
For Mac, Textwrangler


The other gotcha usually comes about from single quotes inside echo statements.
Most phplugins functions you'll use contain an echo statement. The echo is followed by a single quote: (echo '), and then the code you want placed in the html document. That code is followed by another single quote, closing out the echo statement.
But if the code you're trying to place already has one or more single quotes in it, what can happen is that your page (and likely your whole site) will be a blank white page of death.
This is because the echo statement is hitting the first single quote in the code and closing the echo. The code that follows is what will likely be messing things up.

To remedy this, you'll need to "escape" all those single quotes inside any code placed in an echo statement. Do this by preceding any single quote with a backslash (\)

For example, this is the code Google gives you to add the Google font Roboto:

<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>

and this is what you need to do to it

 <link href=\'http://fonts.googleapis.com/css?family=Roboto\' rel=\'stylesheet\' type=\'text/css\'>

One other option is to change those single quotes in the code to double quotes.

 <link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">

Another option is to change the single quotes of the echo statement into double quotes

 echo "
 <link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
 ";

If you do this, you'll need to escape any double quotes that are in the code or text you're echoing. The point is this, no matter what kind of quotes are used for an echo statement, don't use them inside the statement or your site will likely break.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight test site

Online

Board footer

Powered by FluxBB