TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-15-2008, 03:04 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default 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!
__________________
Tanax is offline  
Reply With Quote
Old 11-15-2008, 03:14 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Default

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.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
Tanax (11-15-2008)
Old 11-15-2008, 05:26 PM   #3 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

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 :).
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
The Following User Says Thank You to Runar For This Useful Post:
Tanax (11-15-2008)
Old 11-15-2008, 10:24 PM   #4 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
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 View Post
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
__________________
Tanax is offline  
Reply With Quote
Old 11-15-2008, 11:01 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

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!
__________________
Tanax is offline  
Reply With Quote
Old 11-18-2008, 04:43 PM   #6 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Anyone?? Please I really need this, and I have no idea how to solve this =/
__________________
Tanax is offline  
Reply With Quote
Old 11-22-2008, 05:52 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Solved it! Thanks anyways.
__________________
Tanax is offline  
Reply With Quote
Old 11-22-2008, 06:26 PM   #8 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,298
Thanks: 17
Village Idiot is on a distinguished road
Default

What was the issue?
__________________

Village Idiot is offline  
Reply With Quote
Old 11-22-2008, 07:41 PM   #9 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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?
Enfernikus is offline  
Reply With Quote
Old 11-22-2008, 08:12 PM   #10 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

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>
__________________
Tanax is offline  
Reply With Quote
Old 11-22-2008, 09:06 PM   #11 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,298
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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.
__________________

Village Idiot is offline  
Reply With Quote
Old 11-22-2008, 09:26 PM   #12 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

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.
Enfernikus is offline  
Reply With Quote
Old 11-22-2008, 10:24 PM   #13 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

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.
__________________
Tanax is offline  
Reply With Quote
Old 02-06-2009, 02:31 PM   #14 (permalink)
The Wanderer
 
Join Date: Jan 2009
Posts: 8
Thanks: 1
nightowl is on a distinguished road
Default

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 !
nightowl is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:44 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design