TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-17-2007, 05:13 AM   #1 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default Need help outputting data (while making it easy to skin)

Hello,

I'm curious how you guys code your scripts/programs so it is easy to skin down the line? I was making a script today but I realized the way I was outputting all my code was an absolutely horrible way since I'm hoping to release this for free (or paid) if it ever gets to that point.

I'm a huge fan of the way wordpress does it, but I couldn't seem to get it working like how they have it such as:
PHP Code:
while (the_post()):
// have customized output code
endwhile; 
I couldn't do that, because I wasn't sure what the_post() should be outputting, and how I pass the variable in the while statement so I can list all the info (like if I output an array from the_post() and just use $aArrayVar['row']), but I couldn't get that to work either.

I'm mostly curious if anyone here has a script they release for free or for a fee, and wouldn't mind sending me an example page of code or two so I can see how it is done (OOP would be best since that's what I plan on coding it with).
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 12-17-2007, 05:19 AM   #2 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

AFAIK, the_post() is a function which returns an array.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Old 12-17-2007, 05:20 AM   #3 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default

Okay, I'm thinking of just digging into the core functions of wordpress and looking it up, but I'm kinda lazy, and seeing another example would help a lot, as well.
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 12-18-2007, 07:42 PM   #4 (permalink)
The Acquainted
Upcoming Programmer 
 
CMellor's Avatar
 
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
CMellor is on a distinguished road
Default

Not sure if I understand you 100%, so apologies in advance.

I use Smarty. I have the PHP seperate from the HTML, so skinning would be easy, you wouldn't have to touch the server-side stuff.

In PHP, you'd have:

php Code:
$smarty->assign('name', $username);
and in the HMTL file:

Quote:
{$name}
Which output's the variable $username
Some people consider using Smarty as having to learn a new way of coding, but it's far from that [in my opinion]. For example, the equivalent of an if statement in Smarty is:

html Code:
<!-- GT is an equivalent of '>' -->
{if $x gt $y}
  X
{else}
  Y
{/if}

Smarty PHP
__________________
Not quite a n00b...
CMellor is offline  
Reply With Quote
Old 12-19-2007, 06:54 PM   #5 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Quote:
Originally Posted by CMellor View Post
Some people consider using Smarty as having to learn a new way of coding, but it's far from that [in my opinion].
I don't think that, either. It's merely a coding style with some features.

[quote=CMellor;6828]
html Code:
<!-- GT is an equivalent of '>' -->

...while still having old style comparison operators (> < == != !). I would suggest that you use smarty, too (though I'm not a fan of using smarty in just any project - I believe it should only be used in projects >= medium size).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 12-20-2007, 01:52 AM   #6 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default

I considered smarty, but I personally dislike it, and I could do a much better job doing it using straight PHP in the template files (which I don't want to do).

What I'm trying to achieve is a Wordpress like system, where all you have is the code for the actual loop, an if statement, then the variables/functions within the loop. However, the trouble I'm having is actually making the loop and using a loop to output a list of products from the database.
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:24 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design