-
Posts
19 -
Joined
-
Last visited
Everything posted by Fran
-
[Solved] FormTemplateProcessor - Undefined variable: page
Fran replied to Fran's topic in API & Templates
You made my day Adrian !!! Working perfectly !!! Thanks very much. -
I'm trying to use this code: $this->set('successMessage', '<h2 class="enviado-ok">' . wire('pages')->get("/$page->name/")->mensaje_form_enviado .'</h2>'); inside the init function of FormTemplateProcessor.module and is giving me this error: Notice: Undefined variable: page in /home/pruebase/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module on line 92 Notice: Trying to get property of non-object in /home/pruebase/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module on line 92 This is probably because I'm not really good at php and I guess I can't use the $page variable inside the function right? Does anyone know how could I make this work? Thanks very much.
-
Thanks BitPoet !!! You really save my life on this one !! I can't thank you enough...
-
I'm getting this warning when I try to print an array: Warning: array_values() expects parameter 1 to be array, object given... This is my code: $array = $page->get("planos"); print_r(array_values($array)); I've always thought that $page->get will give you an array, but I'm not so sure now. Thanks for any help.
- 1 reply
-
- array
- array_values
-
(and 2 more)
Tagged with:
-
Thanks Bit Poet for your help... maybe I'm not trying to combine them into one array but rather work with both inside the foreach statement. Please take a look at my response to LostKobrakai above. Thanks very much again.
-
Thanks LostKobrakai. You're being really helpful. This is the first time I have both arrays on the same foreach. I'm intending to use it so I can click on an image from one array and it opens its corresponding bigger(and slightly different) from the other one. I really don't know if I'm going into the right direction with this. I'd like to achieve something like this on the foreach: echo "<div class='col-md-6 col-lg-4'>"; echo "<a href='{$preciosgrandeimg->url}' class='thumbnail' rel='prettyPhoto[galeriaplanos2]'> <img class='img-responsive' src='{$precioschicoimg->url}' /> </a>"; echo "</div>"; Maybe I'm a little more clear with this. Thanks very much for your help.
-
Thanks very much. If you could give me some direction it will be really helpful. I'm a newby and really lost here. Thanks again.
-
Hi, I'm using this piece of code to retrieve the names of two arrays of images and it works really well. But my question is how can I use only one foreach so i can use both arrays inside of it? Thanks very much. $precioschico = $page->get("planos"); $preciosgrande = $page->get("mapas"); foreach( $preciosgrande as $preciogrande ) { echo $preciogrande . '<br/>'; } foreach( $precioschico as $preciochico ) { echo $preciochico . '<br/>'; }
-
Form Template Processor success message in different languages
Fran replied to Fran's topic in API & Templates
I've just realized that it works if we use the path instead of the ID, which was not working: // message output upon successful completion of the form $this->set('successMessage', '<h2>' . wire('pages')->get('contact')->message_sent . '</h2>'); -
Form Template Processor success message in different languages
Fran replied to Fran's topic in API & Templates
It's not working either... Maybe it has to do with the fact that this line is a part of a function? I don't know. I'm not really an expert in php. The function would be: public function init() { // create a page for holding our form fields $this->contact = new Page(); // Template to use for the contact form fields (required). // must be a Template object, it will be assigned to $this->contact. $this->set('template', null); // Optional E-Mail address that form will get submitted to $this->set('email', ''); // Array of field names that are required to complete the submission // if not specified, it will use the admin field settings. // I recommend that you make at least one field required, since this // isn't an admin setting yet. $this->set('requiredFields', array()); // Array of field names that should be skipped when drawing the form $this->set('skipFields', array('title')); // Subject of the email that gets sent $this->set('emailSubject', 'Islandika Contacto Web'); // Optional parent page for the contact. // If ommited, the page will not be saved to the DB. $this->set('parent', null); // message output upon successful completion of the form $this->set('successMessage', '<h2>' . wire('pages')->get(1032)->message_sent . '</h2>'); // date format used for the title's of newly created contact pages $this->set('dateFormat', 'F j, Y, g:i a'); } -
Form Template Processor success message in different languages
Fran replied to Fran's topic in API & Templates
I tried this one out and it gives me a different error now: Error: Call to a member function get() on a non-object (line 91 of /home/islak/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module) the idea is to use the form in several pages, that's why i'm trying to get the field from the page's ID -
I've created a field in the contact page (id:1032) so I can write different success messages according to the language. I'm trying this for the success message in the Form Template Processor module, but without any success: 90. // message output upon successful completion of the form 91. $this->set('successMessage', '<h2>' echo $pages->get(1032)->message_sent '</h2>'); it gives me this error: Parse Error: syntax error, unexpected 'echo' (T_ECHO) (line 91 of /home/islak/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module) What am I doing wrong? Thanks guys...
-
Thanks Diogo I tried this: <?php $lotes = $pages->get(1025)->children(); function getFirstPara($string) { $string = substr($string,0, strpos($string, "</p>")+4); return $string; } foreach ($lotes as $lote) { echo getFirstPara($lote->body); } ?> And it worked great !!!
-
Is there any way to limit the text just to the first paragraph of the body lets say? Thanks very much guys.
-
Thanks Tom... it works perfectly now !!!
-
Im having problems with this little piece of code: $slider = $pages->get("/slider/")->children(); echo $slider(0)->images->first()->url; echo $slider(1)->images->first()->url; echo $slider(2)->images->first()->url; gives me that error: Error: Method name must be a string (line 1641 of /home/islak/public_html/wire/core/WireArray.php) Instead if i use: $slider = $pages->get("/slider/")->children(); echo $slider(1)->images->first()->url; echo $slider(2)->images->first()->url; It works perfectly fine. If I don't use the 0 index everything goes smoothly, but of course I can't show the first children's data. Thanks for any help.
-
Hi guys, I'm trying to create a function to show the first picture of a page based on the rendernav function in _init.php. I'm succeding at showing all the images, but i can't find a way to show just the first image. Thanks in advance for anyhelp & merry christmass !!! function renderNavImages(PageArray $items) { // $out is where we store the markup we are creating in this function $out = ''; // cycle through all the items foreach($items as $item) { //trying to render 1st image foreach($item->images as $image) { //$imagen = $page->image->first(); $out .= "<img src='$image->url' />"; } // render markup for each navigation item as an <li> if($item->id == wire('page')->id) { // if current item is the same as the page being viewed, add a "current" class to it $out .= "<li class='current'>"; } else { // otherwise just a regular list item $out .= "<li>"; } // markup for the link $out .= "<a href='$item->url'>$item->title<br />$item->image</a> "; // if the item has summary text, include that too if($item->summary) $out .= "<div class='summary'>$item->summary</div>"; // close the list item $out .= "</li>"; } // if output was generated above, wrap it in a <ul> if($out) $out = "<ul class='nav'>$out</ul>\n"; // return the markup we generated above return $out; }
-
Thanks very much. It worked perfect !!!
-
Silly question maybe, but I'm new to PW. How can I retrieve the value of a custom field? I'm trying for the label: <?php echo $fields->get("caracteristicas_superficie")->label; ?> And it's working just fine, but: <?php echo $fields->get("caracteristicas_superficie")->value; ?> doesn't work Thanks very much.