PDA

View Full Version : Best way to integrate a php function into custom template.


kickass
12-08-2005, 04:02 PM
To see what I'm trying to do you can look at the index page of my current site, Kickass Web Design (http://kickasswebdesign.com). If you look in the right hand column you'll see in the right hand column a link list of "Most Recent Articles" which is dynamically called from my wordpress blog in the following fashion:

This is what I have in the html/php document before ANYTHING else:
<?php
require_once("blogpath/wp-blog-header.php");
define('WP_USE_THEMES', false);
?>

And this is what I have in the right column in the layout place where I want the title link list to show:

<ul class="blogtitle"><?php wp_get_archives('type=postbypost&limit=5'); ?>[/list]

</div>

I wish to integrate this same treatment into a custom esyndicat template I'm building.

I thought about building a simple php file and calling it in but didn't quite know how to go about it, I'm no php whiz. I also thought about just throwing that top bit in the header.tpl and the other bit in a rightcol.tpl that I've created and called into my index.tpl, but it occurred to me it might screw everything up.

How best can I accomplish this? I didn't wanna muck about the esyndicat code without asking first.

gb
12-08-2005, 04:49 PM
hi kickass!

you can integrate php directly intp templates, see http://smarty.php.net/manual/en/language.function.php.php

greetings,
gb

kickass
12-09-2005, 12:00 AM
Um, Gerwin? Thanks for answering, but that's all greek to me . . . I don't know php nor smarty at all, which is why I asked for help. And since the stuff I wanna integrate is WordPress stuff, and has to be a certain format to work with WordPress (and believe me, getting it to work on a static page was tough!) it makes it even touchier. If anyone can fill me in on a format they think has the best chance of working I'd really appreciate it. When I say I'm clueless about php, I really mean it.

gb
12-09-2005, 04:30 AM
kickass,

smarty is the template engine that is used by esyndicat script. smarty uses php, sure. Smarty has a lot of built in tags and also many plugins. Everything you find at http://smarty.php.net you can basically also use in esyndicat script or install it.

For you, try the following in your template:


<ul class="blogtitle">
{php}
require_once("blogpath/wp-blog-header.php");
define('WP_USE_THEMES', false);
wp_get_archives('type=postbypost&limit=5');
{/php}
[/list]
</div>


Greetings,
gb

kickass
12-09-2005, 02:02 PM
Thanks, I'll give this a try and let you know.

Vasily B.
12-10-2005, 09:10 AM
I have nothing to add. Gerwin knows what he says ;)

2 Gerwin:
don't you mind eSyndiCat Consultant rank? :)

gb
12-10-2005, 10:28 AM
Simon, what an honor. Yes, thank you.
I'm now around the forum quite a lot as I'm working on that project, can't promise where i'll be with my next project. But anyway, thanks.

gb

Greg
12-10-2005, 02:40 PM
Congrats gb on the Consultant rank.
Hold out for more money thou. :lol:

Seriously I hope you stick around for awhile. Your knowledge is appreciated.

Greg

gb
12-10-2005, 05:56 PM
didn't Simon is going to pay for consultants... :wink: anyway, nice side effect.

kickass
12-10-2005, 06:45 PM
Geez, guys, ya hijacked my thread! But that's okay, for good news I'll allow it this time, and the bullwhip will stay in the closet . . . for now . . . Congrats, Gerwin!

vkaryl
12-10-2005, 07:57 PM
Yup, congrats! However, to return this topic to its regularly scheduled programming....

kickass, did the code provided work the way you needed it to work?

Greg
12-10-2005, 08:00 PM
Geez, guys, ya hijacked my thread! But that's okay, for good news I'll allow it this time, and the bullwhip will stay in the closet . . . for now . . . Congrats, Gerwin!

That Simon. Acts like he owns the joint. :lol:

Vasily B.
12-13-2005, 07:14 AM
he :) offtopic here