Hi, I’m trying to store and retrieve information that includes an image and a detailed description. The description should be able to include links and paragraph breaks. However, my images don’t show and any links within the extended description break the array.
The images are saved in the same directory as the text file.
Here’s what my text file looks like:
----
Samples:
Sample1:
Imagefile: sample-1.png
Itemname: Item One
URL: http://www.items.com/item_one
Description: A long paragraph description featuring an (link: http://www.items.com/item_one popup: yes text: outbound link) with some more detailed text.
Sample2:
Imagefile: sample-2.png
Itemname: Item Two
URL: http://www.items.com/item_two
Description: A long paragraph description not featuring an outbound link with some more detailed text.
Sample3:
Imagefile: sample-3.png
Itemname: Item Three
URL: http://www.items.com/item_three
Description: A long paragraph description not featuring an outbound link with some more detailed text.
----
And this is how I ^imagine^ the php should be structured to get this to work…
<?php $samples = yaml($page->Samples()) ?>
<?php foreach($samples as $sample): ?>
<a href="<?php echo $sample['URL'] ?>" target="_blank"><img src="<?php echo $sample["Imagefile"] ?>" alt="<?php echo $sample["Itemname"] ?>" /></a>
<p><?php echo $sample['Description'] ?></p>
<?php endforeach ?>
The HTML output ^looks^ okay, sort of:
<a target="_blank" href="http://www.items.com/item_one">
<img src="sample-1.png"></img></a>
<p>Array</p>
<a target="_blank" href="http://www.items.com/item_two">
<img src="sample-2.png"></img></a>
<p>A long paragraph description not featuring an… </p>
<a target="_blank" href="http://www.items.com/item_three">
<img src="sample-3.png"></img></a>
<p>A long paragraph description not featuring an… </p>
The problem is, the images don’t show and if there is any formating in the long text, all it returns is ‘array’.