TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Need help outputting data (while making it easy to skin) (http://www.talkphp.com/absolute-beginners/1753-need-help-outputting-data-while-making-easy-skin.html)

Andrew 12-17-2007 05:13 AM

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).

Haris 12-17-2007 05:19 AM

AFAIK, the_post() is a function which returns an array.

Andrew 12-17-2007 05:20 AM

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.

CMellor 12-18-2007 07:42 PM

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

xenon 12-19-2007 06:54 PM

Quote:

Originally Posted by CMellor (Post 6828)
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).

Andrew 12-20-2007 01:52 AM

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.


All times are GMT. The time now is 03:16 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0