Hi! I'm beta testing Sparse-PHP and was wondering if there was any way to embed the sparse template tags into a link? What I want to do is make one of my fields clickable so that when the user clicks the link, the ID of the table being displayed is used to pull up a record from another table. I see how to make it work in the constraints on the second page, but I get an XML error if I just try to embed the sparse template tag in the HTML like I do with PHP - eg. <a href="detail.php?id=<sqlfield name='ID' />">. Changing around the order of the quotes doesn't seem to help much. Thanks for your help, in advance!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, unfortunately Sparse won't be able to parse tags inside other tags, that's an XML limitation. There are two ways to deal with it, the pure way and the sort-of-hacking way. 8-) The first way is to use the displayValue attribute like so:
However, you'll then have to be careful, because if you print a </A> tag normally, XML will *also* complain because it won't see a starting <A> tag. So you'd really have to put the entire link in there. 8-\
The second way is just to use PHP code like so:
(I'm not entirely sure this last way will work properly in the current release, but in 1.02, which should be out in a day or two, it's definitely good.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Welcome to Help
Hi! I'm beta testing Sparse-PHP and was wondering if there was any way to embed the sparse template tags into a link? What I want to do is make one of my fields clickable so that when the user clicks the link, the ID of the table being displayed is used to pull up a record from another table. I see how to make it work in the constraints on the second page, but I get an XML error if I just try to embed the sparse template tag in the HTML like I do with PHP - eg. <a href="detail.php?id=<sqlfield name='ID' />">. Changing around the order of the quotes doesn't seem to help much. Thanks for your help, in advance!!
Hi!
Yes, unfortunately Sparse won't be able to parse tags inside other tags, that's an XML limitation. There are two ways to deal with it, the pure way and the sort-of-hacking way. 8-) The first way is to use the displayValue attribute like so:
<sqlfield name="ID" type="text" displayValue='"<a href=\"detail.php?id=$value\">"' />
However, you'll then have to be careful, because if you print a </A> tag normally, XML will *also* complain because it won't see a starting <A> tag. So you'd really have to put the entire link in there. 8-\ The second way is just to use PHP code like so:
<?php
print '<a href="detail.php?id=' . $row['ID'] . '">';
?>
(I'm not entirely sure this last way will work properly in the current release, but in 1.02, which should be out in a day or two, it's definitely good.)
In case you're still there: the new version of Sparse should allow you to do exactly what you wanted the first time around. 8-)
I just noticed that! Thank you so much for adding that functionality!! It seems much more natural to me as a PHP sort of gal...
Not a problem. It fixed a few other things that bugged me as well. 8-)