Jump to content

b.gossler

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

b.gossler's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The cdata response did exactly what i need it to... except that it wont display images that aren't already loaded on the page. Thats something i will attempt to figure out before posting here though. -- Again I would run into the problem of not being able to position the image without going into css and all of that. I want whoever writes the news item to be able to place an image wherever he or she wants. Something like posting on this very forum. You can have text, blah blah, then put an image, then more text. I guess what im trying to say is that i want the image existance and placement in the newsItem to be dynamic, and thats not possible, as far as i can see, in a perfectly formed xml document. Maybe im wrong, but thats what my new eye to php / xml is telling me. Thank you for the responses. I will mark this solved.
  2. Thats the problem I am facing however. I need the ability to include an empty element ie:<img src="blah" /> within the itemContent tag. The reason for this is that images will change from item to item, or sometimes not be present at all. This would be a simple matter if i knew what the images would be for every item (ie: using the code you supplied) but as this is used for news, i dont want to have to go back and change the xml every time an image needs to be displayed. Another problem with using that format you supplied is that there isnt a simple way of formating where the image is displayed within the itemContent. Thank you for your response.
  3. Ive searched and searched, and cant find an answer. So i turn-eth, to you all. Im using XML as a database to store newsItems for display on the front page. I can get everything to display correctly, except for images inside of the content. Im using empty elements in the same format as HTML to keep it simple for those that are going to be actually writing the news items to be displayed. Here is what i have. 112609.xml----------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="xslt.xslt"?> <newsItem> <itemTitle>News Is Working!!!</itemTitle> <itemDate>11-26-2009</itemDate> <itemContent>[b]<img src="../../images/headerOverlay.jpg" />[/b]This is a test of the news... Blah blah blah.</itemContent> </newsItem> handlers.php------------------------------------------------------------- function getNewsItems(){ $path = 'path/to/xml/dir/'; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file !== "." && $file !== ".." && $file !== "xslt.xslt") { $xml = simpleXML_load_file($path.$file); $content = $xml->itemContent; echo "<div id='contentItem'>"; echo "<img src='images/newsItemHeader.png' id='spacer' /><img src='images/newsItemHeader2.png' id='spacer2' />"; echo "<span id='contentHeader'>" . $xml->itemTitle . "</span><span id='date'>" . $xml->itemDate . "</span>"; echo "<div id='contentDetail'>" . $xml->itemContent . "</div></div>"; foreach ($xml->itemContent->children() as $child){ print($child->img); } } } closedir($handle); } } Please note: handlers.php is included on the front page, which then in turn calls the xml files. I can get a print_r of $xml to show the img element, but past that, it will not display. If you want to see the output as it stands now, http://www.cohoproductions.org/dev/2010/index.php That xml file refers to the first news item on the page. my overall question is how do i get those elements inside itemContent to display on the front page IF they are present? do they have to be named each time i wish to use them? or can i use children() and echo them as they come? Forgive my terminology if it is not correct, or confusing. Im relatively new at this, and tbh, i dont write php very often.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.