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
8
Other forums
Hom to make one url to open together with another url
I have a chat, which i want to be opened, as soon as the users login to the site. As it is now, when
iMatch stored value with the current value in a loop
Hello,
I have a MySQL db were I store articles in.
I have a form to fill these article
Simple image grab script.
I was wondering if it was possible and if anyone knew how to make a simple php script that looks at
Retail terminologys not been altered after activing Retail System
Hi, All
After I active Retail System via TCode SWF5, the terms does not been changed, th
Get ID from Database when Posting with a HTML Form
I have a form I am submitting to a MySql database. Each product has an ID # attached to it that auto
Typing math
I've added support for typesetting math using LaTeX on the forums.
Example:
Code: [Select]
Calculating a rating by adding number of points and dividing by number of items
I have a site that users can post links to files to download. They can rate these files on a 1-5 sca
I need help on this PHP code
Hi everybody, I made some kind of mistake while editing the code below. As you see, at the 3 row my
Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.
It'll do the query and then do..
Save username into DB
OkaY so I got my blog to actually save the posts and whatever, all I need now is for it to keep the