Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Themes
Author Message
nextgen
Worker
Worker



Joined: Sep 28, 2006
Posts: 241

PostPosted: Wed Oct 03, 2012 10:54 am Reply with quote

If i had to use html pages in a theme i know i can make them php so all i need to do is place the

Code:
<?PHP  "STUFF"  ?>
at the beginning and end of the document or is there a way i can secure the code so it not a liability to anyones website ?

_________________
alterednuke.com Your source for Ravennuke themes. 
View user's profile Send private message Send e-mail
wHiTeHaT
Life Cycles Becoming CPU Cycles



Joined: Jul 18, 2004
Posts: 579

PostPosted: Thu Oct 04, 2012 3:13 pm Reply with quote

check : http://php.net/manual/en/function.isset.php
 
View user's profile Send private message Send e-mail
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Thu Oct 04, 2012 4:05 pm Reply with quote

Good point about isset. You can search the RN code for examples of use.

If you are including a PHP file to output HTML you could use example #3 or #4 @ the top of your files

http://rnwiki.ravennuke.com/wiki/RNTeam:Coding_Standards#File_Security

I generally don't like jumping in and out of PHP to output HTML, and prefer to use echo '';

From a code readability standpoint I don't really like seeing this, but it's just my preference..

<h2><?php echo $title; ?></h2>

better
echo '<h2>' . $title . '</h2>';

You just have to make sure to escape any single quotes, or convert them to double quotes

broken
echo '<h2 class='title'>Lamb</h2>';
echo '<h2>Mary's Lamb</h2>';
better
echo '<h2 class="title">Lamb</h2>';
echo '<h2>Mary\'s Lamb</h2>';
 
View user's profile Send private message Visit poster's website
wHiTeHaT







PostPosted: Thu Oct 04, 2012 4:30 pm Reply with quote

I probably understood his question wrong.

I thought he meant that if he created a theme and the client doesn't have for example a specific navigation menu installed, so the theme wont go look for it and skips the test.

Else the TS should clear up his question.
 
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1775

PostPosted: Thu Oct 04, 2012 5:14 pm Reply with quote

In all inlcuded files you don't need the php closing tag like this "?>"

Code:
<?php // file starts here

echo '<h2>' . $title . '</h2>';


If you have some echo calls to each other, then can you use this one:

Code:
echo '<h2 class"title">' , $title , '</h2>'

   , '<div class"hometext">' , $hometext , '</div>'
   , '<div class"bodytest">' , $bodytest , '</div>';


If you get an break with a function between the echo lines:

Code:
echo '<h2 class"title">' , $title , '</h2>'

   , _LANG_CONSTANT1 , '<br />'
   , '<div class"hometext">' , $hometext , '</div>'
   , '<div class"bodytest">' , $bodytest , '</div>';
test();
echo '<div class"something">' , $something , '</div>'
  , _LANG_CONSTANT2 , '<br />'
  , '<div class"anyway">' , $anyway , '</div>';


Thus you avoid you getting the same echo calls. This saves a lot of code in large scripts.

The most developers wants a clear code in the browser without have all in one line. The problem with the echo calls is, you have no linebreaks in the sourcecode view of your browser and all is in one line.

If you want now make an linebreak after the the closed divs in the sourcecode view, then you can use the constant PHP_EOL or you make double quotes. But double qoutes are not the best solution. I believe i have sent you for a while some links for the using of PHP_EOL ... any way here again a example:

line breaks with PHP_EOL:

Code:
echo '<h2 class"title">' , $title , '</h2>' , PHP_EOL

   , _LANG_CONSTANT , '<br />' , PHP_EOL
   , '<div class"hometext">' , $hometext , '</div>' , PHP_EOL
   , '<div class"bodytest">' , $bodytest , '</div>' , PHP_EOL;


http://youngdutchdesign.com/linebreaks-with-phpeol
http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-php-eol
http://stackoverflow.com/questions/6810557/what-is-the-benefit-of-n-and-php-eol-in-php

or line breaks with double quotes:

Code:
echo '<h2 class"title">' , $title , '</h2>' , "\n"

   , _LANG_CONSTANT , '<br />' , "\n"
   , '<div class"hometext">' , $hometext , '</div>' , "\n"
   , '<div class"bodytest">' , $bodytest , '</div>' , "\n";
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Themes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©