icreation Posted March 7, 2016 Share Posted March 7, 2016 HiWith 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 More sharing options...
adrian Posted March 7, 2016 Share Posted March 7, 2016 Looks like the homeboximage field is not set to "1" for the Max Files Allowed setting. Either change that, or do: echo $homebox->homeboximage->first()->url; 2 Link to comment Share on other sites More sharing options...
icreation Posted March 7, 2016 Author Share Posted March 7, 2016 Funnily enough the field is set to Maximum files allowed = 1 but the ..first()-> statement has worked. Many thanks. Link to comment Share on other sites More sharing options...
adrian Posted March 7, 2016 Share Posted March 7, 2016 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 More sharing options...
bernhard Posted March 7, 2016 Share Posted March 7, 2016 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 6 Link to comment Share on other sites More sharing options...
adrian Posted March 8, 2016 Share Posted March 8, 2016 Nice one bernhard - I totally missed the line in the OP noting that PW was being bootstrapped 1 Link to comment Share on other sites More sharing options...
tpr Posted March 8, 2016 Share Posted March 8, 2016 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 2 Link to comment Share on other sites More sharing options...
WillyC Posted March 8, 2016 Share Posted March 8, 2016 include("/home/shutterblue/public_html/content/index.php"); $wire->pages->setOutputFormatting( true ); // u cansadd.this when boot trap $homepage = $wire->pages->get(1); 2 Link to comment Share on other sites More sharing options...
icreation Posted March 24, 2016 Author Share Posted March 24, 2016 Just seen this WillyC - thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now