Jump to content

Processwire 3 - using the API in Open Cart - wee hitch


icreation
 Share

Recommended Posts

Hi
With Processwire 3.x it seems that now the API really works in other applications that didn't before.
 
Open Cart is a good open source e-commerce platform but the CMS capabilties are limited. I always wanted to be able to integrate PW fields into OC and now it seems possible. However there is a problem that I cannot overcome.
 
Once I add in the ref to the index.php I have full access to all the fields in $page->id == 1

This is added to the home.tpl template page in Open Cart and seems to mostly work.

include("/home/shutterblue/public_html/content/index.php");
$homepage = $wire->pages->get(1);

from there all the fields can be echo'd, for example: $homepage->title, etc.

I have a repeater and 2 text fields:

The repeater is named 'homeboxes' - with fields called 'homeboximage', 'homeboxtitle'.

<?php foreach($homepage->homeboxes as $homebox): ?>
    <div class='col-xs-3 default-mobile'>
	    <div class='block-content'>
	    	<img src="<?php echo $homebox->homeboximage->url; ?>" alt="<?php echo $homebox->homeboxtitle; ?>" class="img-responsive" />
        	<div class="bs-text-down text-center">
				<?php echo $homebox->homeboxtitle; ?>
        	</div>
	    </div>
    </div>
<?php endforeach ?>

The 'homeboxtitle' echos out pefectly but the 'homeboximage->url' does not.

Instead of showing image url's like this:

<img src="/content/site/assets/files/1021/crop_5d3_0451_fr.jpg" alt="Home box title" class="img-responsive" />

I get this:

<img src="/content/site/assets/files/1021/" alt="Home box title" class="img-responsive" />

Any idea?

Link to comment
Share on other sites

Funnily enough the field is set to Maximum files allowed = 1 but the ..first()-> statement has worked.

Many thanks.

Sounds like output formatting may be off, or you have changed the Formatted Value for the field - what is that set at?

Also, try this just before outputting the image and let me know what it returns.

echo $page->of();
Link to comment
Share on other sites

outputformatting is always off when bootstrapping pw so your file-fields will always return arrays no matter what the setting in the admin is  ;)

ps: yeah - the once in a lifetime moment when adrian has already posted a reply and i added (little) additional value with my answer. i will print that post and hang it up in my living room ;):D

  • Like 6
Link to comment
Share on other sites

Nice one bernhard - I totally missed the line in the OP noting that PW was being bootstrapped :)

You know that a new sanctuary is just being built for you somewhere in Austria :)

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...