 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
11-15-2008, 04:04 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Need some help with PHPTAL
Hi!
I'm wondering what's wrong with this:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title tal:content="title">Your site name here</title>
</head>
<body>
<table tal:condition="show">
<caption>Images</caption>
<tbody>
<tr tal:repeat="image images">
<td tal:define="global img string:$path thumb/ $image/image_path"><img src="${img}" /></td>
</tr>
</tbody>
</table>
<div tal:condition="not:show">This user has no images</div>
</body>
</html>
Gives me:
Code:
Message: Unable to find path images in current scope
I'm new to PHPTAL, so I really need help =/
Thanks in advance!
__________________
|
|
|
|
11-15-2008, 04:14 PM
|
#2 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Do you set the base path somewhere? Though my real reason for replying isn't specifically about PHPTAL as I've never used it, but just to say that whenever I see PHPTAL it always reminds me of PiHKAL because of the similarity at first glance!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
|
The Following User Says Thank You to Wildhoney For This Useful Post:
|
|
11-15-2008, 06:26 PM
|
#3 (permalink)
|
|
The Contributor
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
|
You will have to define images somewhere in your PHP script, then send it to the template engine, like this:
PHP Code:
$template->images = $some_array_with_data;
If that did not work, please let us see some PHP code :).
|
|
|
|
The Following User Says Thank You to Runar For This Useful Post:
|
|
11-15-2008, 11:24 PM
|
#4 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by Wildhoney
Do you set the base path somewhere? Though my real reason for replying isn't specifically about PHPTAL as I've never used it, but just to say that whenever I see PHPTAL it always reminds me of PiHKAL because of the similarity at first glance!
|
No need to set a base path with PHPTAL, but thanks!
Quote:
Originally Posted by Runar
You will have to define images somewhere in your PHP script, then send it to the template engine, like this:
PHP Code:
$template->images = $some_array_with_data;
If that did not work, please let us see some PHP code :).
|
Thank you! This worked.
Problem solved 
__________________
|
|
|
|
11-16-2008, 12:01 AM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Okey, so a new problem occured. Not really an error, but a problem.
I got this:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title tal:content="title">Your site name here</title>
</head>
<body>
<span tal:condition="showUploadlink"><a href="upload.php">Upload an image</a></span>
<br /><br />
<table tal:condition="showImages" cellspacing="5px">
<caption>Images</caption>
<tbody>
<tr>
<td tal:repeat="image images">
<img src="${path}/${image/image_path}" />
</td>
</tr>
</tbody>
</table>
<div tal:condition="not:showImages">This user has no images</div>
</body>
</html>
Problem is that the td:s keep going on forever. If I put an array of images, that is 100 images, it will list 100 images on the same row. If I place the tal:repeat in the tr tag instead, it will list 100 images on 100 rows. So how can I make a repeat that makes a new tr after say.. 6 images?
So that it produces this:
Code:
<tr>
<td>img</td>
<td>img</td>
<td>img</td>
<td>img</td>
<td>img</td>
<td>img</td>
</tr>
<tr>
<td>img</td>
<td>img</td>
<td>img</td>
<td>img</td>
<td>img</td>
<td>img</td>
</tr>
etc..
Thanks in advance!
__________________
|
|
|
|
11-18-2008, 05:43 PM
|
#6 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Anyone?? Please I really need this, and I have no idea how to solve this =/
__________________
|
|
|
|
11-22-2008, 06:52 PM
|
#7 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Solved it! Thanks anyways.
__________________
|
|
|
|
11-22-2008, 07:26 PM
|
#8 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
What was the issue?
|
|
|
|
11-22-2008, 08:41 PM
|
#9 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Quote:
Originally Posted by Tanax
Solved it! Thanks anyways.
|
As Salathe has mentioned before, it'd be more useful if you took two to five minutes to outline the problem ( even that you don't really need to do since the thread has the problem in question outlined ) and the solution in a semi-detailed manner rather then replying with the above or something like it.
That being said, what was the issue?
|
|
|
|
11-22-2008, 09:12 PM
|
#10 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
It's funny that you didn't even seem to care before, and now you want to know everything. If I wouldn't have posted that I solved it, noone could care less if I solved it, or not. But now that I did, I get 2 replies almost directly.
The issue(problem) was that I wanted to limit the number of results PER row. And if I placed the repeat in the td tag it would write alot of results on the same row. If I were instead to place the repeat in the tr tag, it would just write alot of results with only 1 result per row. I wanted to limit this so I could have for example 6 results per row.
The solution was to use array_chunk:
HTML Code:
<table tal:condition="showImages" cellspacing="5px">
<tbody>
<tr tal:repeat="chunk php:array_chunk(images, 5)">
<td tal:repeat="image chunk">
<a href="view.php?image=${image/image_id}"><img src="${path}/${image/image_name}" border="0" /></a>
</td>
</tr>
</tbody>
</table>
__________________
|
|
|
|
11-22-2008, 10:06 PM
|
#11 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by Tanax
It's funny that you didn't even seem to care before, and now you want to know everything. If I wouldn't have posted that I solved it, noone could care less if I solved it, or not. But now that I did, I get 2 replies almost directly.
|
If I didn't give a shit, I would not have asked what the problem was. If I knew the issue, why on earth would I have withheld it? It is not that I didn't care, it is that I did not know the answer to your question. But now that you found it, it would be useful for everyone if you posted the solution.
Don't accuse us of not caring, if we didn't care we wouldn't be on this forum.
|
|
|
|
11-22-2008, 10:26 PM
|
#12 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
If I knew the answer I would've posted, there's not much use in posting in a thread of which the original statement or question you've no knowledge of.
|
|
|
|
11-22-2008, 11:24 PM
|
#13 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Look at it from my point of view. I didn't get any replies(I got replies to my first question, yes. But I meant my second question). My conclusion was that noone was interested, nor cared about it. Then why should I post how I solved it, if I thought noone was interested in it?
And I meant that it didn't seem like you cared BEFORE I solved it. When I solved it, obviously I saw you were interested. But how should I know that before? I couldn't. Hence I didn't post the solution.
But now I did.
__________________
|
|
|
|
02-06-2009, 03:31 PM
|
#14 (permalink)
|
|
The Wanderer
Join Date: Jan 2009
Posts: 8
Thanks: 1
|
if you post a question, and you find the answer yourself, it's just polite to post the answer. a lot of people are reading, but you can't expect everyone who doens't know the answer to say "i care, but i don't know the answer".
more: i just dropped in now, and I find the solution to a problem wihtout having to ask. you just shared vital information with the community, which is great !
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|