Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Having an inssue with WordPress (NOT using Woz_en!)

Having an inssue with WordPress (NOT using Woz_en!)

Locked

Views: 1,046

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
11 May 2009, 1:17 PM
#1
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Having an inssue with WordPress (NOT using Woz_en!)

Hey all,

I've added WordPress to a customized ZenCart site. I'm really well-versed in WordPress, and I'm better than i used to be at Zencart. So when the client asked to have a WordPress blog added to the site, I did so. Orginally, I used Woz_en - but the current version of WordPress is 2.7.1, and we had some serious issues in using it. I found some solutions in the thred, but there were still problems, blah blah and to make life easier I just did a separate install. no biggie. The clients wanted the most recent post pulled intot he ZenCart index page, so I simply did what I usually do when someone wants a static site to display WP stuff: I put in a call to the blog_header.php file.

It worked like a charm. In the html_header.php file, I just put this in at the top:

/** WordPress **/
$basehref = $_SERVER['DOCUMENT_ROOT'];
require($basehref . '/blog/wp-blog-header.php');

It has to appear before anything else - if it doesn't then you get those "headers already sent" errors.

Anyway, so it worked fine - but we've recently discovered that when you go to check out, as soon as you hit the"checkout" button (and thus go to checkout_shipping.php) that page goes blank. I was pretty sure it had to do with the wp-blog-header.php call, because once you get into the login areas, you enter the https zone. (For the record, https is NOT enabled right now - so initially I'd think it would have something to do with that, but it's definitely not that) Going along with that, I removed the call to the wp-blog-header.php, and the checkout_shipping pages worked just fine.

So I tired using a conditional in the html_header.php - since all we want to do is pull in the WordPress content on the index page, I changed it to this:

if($this_is_home_page) {
$basehref = $_SERVER['DOCUMENT_ROOT'];
require($basehref . '/blog/wp-blog-header.php');
}

and of course ALL of the site went blank. Which, honestly, woudl make sense. I mean really, I've just placed the whole site in a catch-22 right?

So my question is this: how can I make the WordPress stuff get pulled into the index page without using a conditional, and without making the checkout process stop functioning?

I was thinking maybe I could do the RSS feed trick (there's a way where you can grab the content of the WP RSS feed and pull it into a static page without the need of the wp-blog-header.php file) but I didn't know how well ZenCart worked with RSS feeds. But if anyone has a suggestion on how to get around my dilemma, I'd appreciate it.

Thanks!

2 Jun 2009, 2:50 PM
#2
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: Having an inssue with WordPress (NOT using Woz_en!)

For the record, I found a solution to this problem. It's using a small snippet of PHP code that's placed in the templates/tpl_index_default.php file.

<div class="wordpress">
<?php
// rss page from your blog -
$feed_url = "PUT WORDPRESS FEED URL HERE";

# INITIATE CURL.
$curl = curl_init();

# CURL SETTINGS.
curl_setopt($curl, CURLOPT_URL,"$feed_url");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);

# GRAB THE XML FILE.
$xmlTwitter = curl_exec($curl);

curl_close($curl);

# SET UP XML OBJECT.
# Depending on your PHP version, use one of the lines below.
# Comment out the one you are not using.
//$xml = new SimpleXMLElement($xmlTwitter);
$xml = simplexml_load_string($xmlTwitter);

// How many items to display
$count = 1;

// How many characters from each item
// 0 (zero) will show them all.
$char = 200;
   
   foreach ($xml->channel->item as $item) {
	    if($char == 0) {
  	      $newstring = $item->description; 
  	    } else { 
  	      $newstring = substr($item->description, 0, $char); 
  	    } 
  	    
  	    if($count > 0) { ?>
  	      <h2> <a href="<?php echo $item->guid ?>"><?php echo $item->title ?></a></h2>
		    <div class="entry">
		    <?php echo $newstring ?>... <br />
		    <a href="<?php echo $item->guid ?>">read more »</a>
		    </div>
	<?php }
$count--;
}
?>
<!--/wordpress-->
</div>

I wish I could remember where I found this snippet of code so i could credit the author, but it works like a charm - pulls in the most recent post via the RSS feed and plops it right on the index page. Hope it helps someone else!