Page 1 of 1

Best Practice Approach to My Situation?

Posted: Fri Apr 25, 2008 3:10 am
by MKayHavoc
Hi,

I'm building an Object Orientated, Smarty Template driven, Intranet.

It's the first thing I've built completely OOP, and the first time I've used Smarty.

Here's what currently happens. Content and Navigation are dynamically generated from a database, however I'm now building a Telephone Directory that will pull a list of users from Active Directory LDAP. That's fine I can code that. But how would I integrate it into my system? I obviously want it to be displayed through my template system but how is best?

Any advice?

Re: Best Practice Approach to My Situation?

Posted: Fri Apr 25, 2008 4:10 am
by Kieran Huggins
take a look at the LDAP examples in the PHP manual: http://ca.php.net/manual/en/ldap.examples.php

specifically:

Code: Select all

   echo "Getting entries ...<p>";
    $info = ldap_get_entries($ds, $sr);
    echo "Data for " . $info["count"] . " items returned:<p>";
 
    for ($i=0; $i<$info["count"]; $i++) {
        echo "dn is: " . $info[$i]["dn"] . "<br />";
        echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";
        echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />";
    }
Is that what you're looking for?

Re: Best Practice Approach to My Situation?

Posted: Fri Apr 25, 2008 4:24 am
by MKayHavoc
Actually no, how LDAP actually works is fine. I've got the script to make it all work and everything. What I mean is, I pass to my smarty template a variable called "content", which typically is content pulled from my database.

On this occasion I want, in place of the content, a directory generated from a script that's using ldap.

What I mean is my system is build around pulling out this database stored content. How am I bested modifying the system so that on occasion I can display a different type of content, i.e. no pulled from the database, but instead from a separate script.

Hope that makes sense.

Re: Best Practice Approach to My Situation?

Posted: Fri Apr 25, 2008 9:02 am
by Mordred
Should be identical - only instead of pulling data from SQL and passing it to Smarty, you pull it from LDAP and pass it to Smarty. Maybe your code is (dis)organized in a way that doesn't allow that? Paste a short sample of how you pull a var from SQL and display it.