Jump to content

millsy007

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Everything posted by millsy007

  1. I have a wordpress blog in a subdirectory of my site, I want to keep it seperate from the rest of my site, but would like to access the latest posts on my sites homepage. I am trying to do this by reading the blog feed and displaying it but the code I have found relies on a wordpress function, but as I have this installed on a different section of my site I cant access that functionality. Is there a way I could modify the following to get out what I need? <?php require_once(ABSPATH . WPINC . '/rss-functions.php'); $rss = fetch_rss('http://www.mysite.nl/blog/rss'); echo '<ul>'; for($i=0;$i<5;$i++) { $item=$rss->items[$i]; echo '<li><a href="' . $item['link'] . '" title="' . $item['title'] . '">' . $item['title'] . '</a></li>'; } echo '</ul>'; ?>
  2. Your a star! Got it to work for the previous too! Cheers
  3. Hello I have some xml (a sitemap). I pass this into my php code and use the current server url to find the relevant record within the sitemap. I then want to use the array made from the sitemap to find what the next record in the sitemap is and use this for a next link on my page. So I would have: <?php $domain = $_SERVER['HTTP_HOST']; $path = $_SERVER['SCRIPT_NAME']; $currenturl = "http://" . $domain . $path; include 'sitemap.php'; $xml = new SimpleXMLElement($xmlstr); foreach ($xml->url as $url) { if ((string) $url->loc == $currenturl) { //TO DO: Go to the next record in the sitemap/array , get this url and set it to = &nexturl echo '<div class="navigation-div"><ul class="navigation"><li class="next"> <a href="', &nexturl ,'">NEXT</a></li> </li></ul></div>'; } } ?> <?php $xmlstr = <<<XML <?xml version='1.0' standalone='yes'?> <urlset> <url> <loc>http://www.page.nl/home.php</loc> <priority>1.00</priority> <changefreq>daily</changefreq> </url> <url> <loc>http://www.page.nl/about.php</loc> <priority>0.80</priority> <changefreq>daily</changefreq> </url> </urlset> XML; ?> So for example if the current page was http://www.page.nl/home.php I would want the NEXT link to bet set to http://www.page.nl/about.php Thanks ???
  4. Thanks. But my Problem is that the HTML pages have already been created for 100s of pages using adobe contribute (where they will also be edited) I would like therfore to be able to access the current HTML titles and assign them as a variable?
  5. I would like to be able to create a $pagetitle variable in php for my pages that will contain the current HTML page title for that page. I have had a look around but there doesnt seem to be any class/code out there to do this?
  6. Would it just be a case of modifying this line: for($i=0; $i<$index['Listings'][1]; $i++) To only pass in the number eg ['Listings'][5] for the page I wanted and then remove the increment ; $i++ ?
  7. I have php code that uses an XML file to display in an HTML page the 'Next' and 'Previous' pages for that page. The code currently selects ALL of the XML records and then displays them on the page. What I would like to be able to do is have the HTML only display the next and previous links for the current page. What would be the best way to do this? Perhaps Select only where the XML Title = the HTML page title? ??? XML <?xml version="1.0" encoding="ISO-8859-1"?> <Listings> <Count>2</Count> <Listing> <Title><![CDATA[Food and Drink]]></Title> <PREVURI>http://www.page.nl</PREVURI> <NEXTURI>http://www.page.nl/info/Location.php</NEXTURI> </Listing> <Listing> <Title><![CDATA[Location]]></Title> <PREVURI>http://www.page.nl/Food-and-Drink/index.php</PREVURI> <NEXTURI>http://www.page.nl/info/Facilities.php</NEXTURI> </Listing> </Listings> PHP <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php // read xml file into string $text = file_get_contents("sample.xml"); if(!$text) { die("ERROR: Unable to read file"); } // parse the xml into structure $p = xml_parser_create(); xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0); xml_parse_into_struct($p, $text, $vals, $index); xml_parser_free($p); // read data of interest from structure into array: for($i=0; $i<$index['Listings'][1]; $i++) { foreach(array('Title', 'PREVURI', 'NEXTURI') as $key) { $data[$i][$key] = $vals[$index[$key][$i]]['value']; } } // output HTML: foreach($data as $val) { echo <<<XML <a href="{$val['PREVURI']}"><small>PREVIOUS</small></a> <h3>{$val['Title']}</h3> <a href="{$val['NEXTURI']}"><small>NEXT</small></a> <br> XML; } ?> </body> </html>
  8. I have some php code that takes a csv file and outputs it to an html table. The problem is that I only want to show certain fields / columns from the csv file in my html table. In this case they are the 5th and 6th columns (named ResponseText and DateAdded) Where in the code could I make this selection? PHP Code: <?php /*/-------------------------------------------------------------------\ | Original Name : csvview.php | | Origional Author : Neil Maskell | | Revised by: Charles W. Reace, Jr. | | | | Function : Reads a specified CSV file (Comma seperated) and | | converts it into a readable HTML table. | | | | You could set up a html form with an input field | | called filename. Then use csvview.php as the action. | | | | the reason cache is being disabled is because if you | | update the csv file the cache doesnt realise and shows| | an older version of the information. | | | | The CSV files should (and normally are) in the format:| | field1,field2,field3,field4 | | | | thanks to Charles W. Reace, Jr. | | now this works with csv files in the format: | | "field1","field2","field3","field4" | | | \-------------------------------------------------------------------/ */ // $filename = "ResponsesText.csv"; // File to open. quote out this variable if you are using a form to link to this script. /* No cache!! */ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 /* End of No cache */ # bool viewlog(str filename) # parses input CSV file into table rows # returns FALSE if cannot open file, otherwise TRUE function viewlog($filename) { $fp = fopen($filename,"r"); if($fp === false) { return(false); } while(($line = fgetcsv($fp, 1000)) !== false) { echo "<tr>"; foreach($line as $value) { echo "<td>$value</td>"; } echo "</tr>\n"; } return(true); } echo "<html><head><base href=\"./\"><title>CSV File Viewer</title></head><body bgcolor=silver>"; // Start the table definition of your choice echo "<table>\n"; viewlog($filename); echo "</table></body></html>"; ?>
  9. The problem is my site has not been set up as most blog sites, ie the pages are not stored within a database with IDs. They are however saved hierarchically within the sitemap so I was hoping to use this as the basis for the previous / next navigation? Could php read the sitemap xml file and navigate though this?
  10. I would like to set up some navigation similar to that used on many blog sites where the user will have the option at the top of the page of 'previous' 'next' and 'home' for my pages. My issue is that I would not want to hard code in the next and previous pages within the site, but would instead it like to work automatically by working off either the sitemap or the folder structure of the website to workout what the next page within this stucture was and link to that. Any ideas or examples where this has been done?
  11. I have set up two pages, content.php and template.php, I was the content.php file to contain a variable that will contain all the html for my content that will then be displayed within my template.php file, mostly this works fine. However the problem I have is that I want additional html in my content.php file so that when other people are editing it looks more like the finished file. My problem is that when I add this additional html it is being passed into the template.php file even though it is not within the content variable. Hopefully this code snippet will explain it: template.php <html><head><head><body <table width="100%" cellpadding="10" cellspacing="0"><tr><td width="30%" valign="top" bgcolor="#EEEEEE"> Beach Hostel is located right next to one of Holland’s beautiful beaches. There’s nothing that can beat the sound of waves and the tranquility of the beach-life, especially after you’ve been surrounded by the madness of the city (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the best chill out spot you can imagine; in this backpacker hostel you can relax, smoke, hang out with friends, party or challenge your limits and abilities in various beach sports! </td> <td width="70%" valign="top"> <?php echo $content; ?> </td></tr></table> </body></html> content.php <p>TEST CONTENT - this is displayed even though it is outside the php tags?</p> <?php ob_start(); ?> <p>The Beach Hostel is located right next to one of Holland’s beautiful beaches. There’s nothing that can beat the sound of waves and the tranquility of the beach-life, especially after you’ve been surrounded by the madness of the city (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the best chill out spot you can imagine; in this backpacker hostel you can relax, smoke, hang out with friends, party or challenge your limits and abilities in various beach sports!</p> <?php //Assign all Page Specific variables $content = ob_get_contents(); ob_end_clean(); //Apply the template include("template.php"); ?>
×
×
  • 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.