PHP template help


Posted on 16th Feb 2014 07:03 pm by admin

Ok, I don't know if anyone can help me but I am using PHP templates to make a site. I am a newbie and so I am finding this quite difficult so I thought I would ask some folks much better than me.

I have two pages at work here; profile.tpl and profile.php.

The profile page has <Zone> tags in it. I am attempting to pulll a list of contacts from the database and display the picture and user information. This part works fine.

The part I am having trouble with is displaying a different zone if there are no users to associated with the current profile.

I am using a if statement to do this (I did not write this if statement so forgive my ignorance about how it works) and I want an else to take place if there is no contacts that will display an alternative zone.

This is the code from the profile template page:

<ZONE contactsTab enabled>
<div class="dashContent">
<LOOP contactEntity>
<div style="float:left;">
<a href="?L=users.profile&id={contact.id}">
<img src="system/image.php?file={contact.mainpicture}" alt="[Picture {150}]" hspace="2" border="0" id="picture" /></a>
<br />
<a href="?L=users.profile&id={contact.id}">{contact.username}</a></div>
</LOOP contactEntity>

<ZONE addtocontactstab enabled>
<a href="?L=contacts.adduser&id={user.id}">[Add {user.username} to my contacts list {8225}]</a>
</ZONE addtocontactstab enabled>
<div class="clear"></div>
</div>
</ZONE contactsTab enabled>

<ZONE contacts disabled>
<div>This user does not have any contacts at this time.</div>
</ZONE>

This is the code from the supporting PHP page:

$userContactsArray = unpk(_fnc("user", $_GET["id"], "contacts"));

$i=0;


if (is_array($userContactsArray)) foreach($userContactsArray as $userContactGroup => $contactsUsersArray) {


if (is_array($contactsUsersArray)) foreach($contactsUsersArray as $contactsUserID) {


$thirdUserContactsArray = unpk(_fnc("user", $contactsUserID, "contacts"));


if (is_array($thirdUserContactsArray) && _fnc("in_multiarray", $thirdUserContactsArray, $_GET["id"])) {


if ($i==0) $tpl->Zone("contactsTab", "enabled");



$contactEntityArray[$i]["contact.username"] = _fnc("user", $contactsUserID, "username");
$contactEntityArray[$i]["contact.id"] = $contactsUserID;
$contactEntityArray[$i]["contact.mainpicture"] = _fnc("user", $contactsUserID, "mainpicture");

$i++;

}
}


}

else $tpl ->Zone("contacts", "disabled");


if (isset($contactEntityArray)) $tpl -> Loop("contactEntity", $contactEntityArray);

Any help solving this would be more greatly appreciated

No comments posted yet

Your Answer:

Login to answer
250 Like 8 Dislike
Previous forums Next forums
Other forums

adding 0 to numbers
Hey guys i need to create a 00001 number in a loop. Is there a better way of forcing a 5 digit numbe

upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi

help retrieiving results and doing pagination
Having some trouble trying to get the results to show on more than just one page.

What is ha

Pls help with PHP
Pls can anyone direct me on how to create a user account for a customer. For example i want know if

Sessions Value Not Saved
Hi,

Im making a login form and im using this code:
Code: if($login=="true"){

Memory Allocation
Hi folks,
see this ex:

int v=5;
v=v+10;

then what will do the compiler before th

Inserting 100x and 100y coordinates in mysql table - easy
Is there a way to insert this data into a mysql table named 'map' with the fields: 'x int 3' , 'y in

Call db table from any PHP file
Hi,

I want to be able to call a database table that will be setup in another file called init

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

my login script page is not working on remote computers
hi my login is working on my computer, but when i tried 2 computers from 2 different locations, they

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash