Search the Community
Showing results for tags '$page'.
-
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:
-
After getting a lot more confident with my php skills, I thought I would try condensing my file structure by using the _func.php in my templates. I thought this would be a great way to cut down on my includes (Currently at around 12). However, I ran into a bit of a snag. From my reading, I understand that $page is not a global variable, and that I could use something like: $pages = wire('pages'); to get the desired result. However, I must not be using this right :). Here Is what I have: function basicPage(){ $pages = wire('pages'); $output = ""; $output .="<div class=\"container\">"; $output .="<div class=\"row\">"; $output .="<div class=\"col-md-12\">"; $output .="<h1><?php echo $page->title; ?></h1>"; $output .="</div>"; $output .="</div>"; $output .="<div class=\"row\" id=\"tinyInfo\">"; $output .="<div class=\"col-md-12\">"; $output .="<ul class=\"about\">"; $output .="<li>{$pages->about}</li>"; $output .="</ul>"; $output .="</div>"; $output .="</div>"; $output .="<div class=\"row\">"; $output .="<div class=\"col-md-12\" id=\"maincopy\">"; $output .="{$pages->maincopy}"; $output .="</div>"; $output .="</div>"; $output .="<div class=\"row\">"; $output .="<div class=\"col-md-12\">"; include './includes/slider.php'; $output .="</div>"; $output .="</div>"; echo $output; } This doesn't seem to be outputing anything into my template. Have I missed a crucial step here, or is the "output" method I have chosen not even a great way to set this up? I understand includes wont work this way, but if anyone has suggestions on this I would gladly like to hear them. Sorry for a post with so many questions, but I am just stumped.
-
Hi there, I've got some code that bulk uploads the contents of Tab Delimited files into our Processwire CMS. It looks like the $page->save functionality stops working after a certain number has been processed. Haven't worked out where it starts failing yet but all the rows towards the bottom have certainly failed. Unfortunately, there isn't anything in the error logs (at least the php error log) to see if there is an issue. I have tested the rows that were not working by putting them individually in seperate tsv files to prove that the code works, the data is clean and it actually updates the CMS. I was wondering if there's an internal limit on how many page saves the CMS can handle? Thanks in advance. Below is the copy of the code I'm using to do a bulk upload. I'm using a 3rd party module called SimpleExcel to help with the reading and processing of the tab delimited files. $_rowStart = 13; $_colTitle = 1; //A $_colMeta = 10;//J Meta Title = SEO Title $_colDesc = 11;//K $_colURL = 12;//L $_colURLnew = 13;//M $_colCanonical = 14;//N $_colAlt = 15;//O $_colKeywords = 16;//P $excel = new SimpleExcel('TSV'); $excel->parser->loadFile(__DIR__."/{$file}"); //$url = $excel->parser->getCell($_rowStart, $_colURL ); $row= $_rowStart; do { $title = $excel->parser->getCell($row, $_colTitle ); $meta = $excel->parser->getCell($row, $_colMeta ); $desc = $excel->parser->getCell($row, $_colDesc ); $url = $excel->parser->getCell($row, $_colURL ); $urlnew = $excel->parser->getCell($row, $_colURLnew ); $canonical= $excel->parser->getCell($row, $_colCanonical ); $alt = $excel->parser->getCell($row, $_colAlt ); $keywords= $excel->parser->getCell($row, $_colKeywords ); $internal= str_replace("http://sprachspielspass.de",'',$url); $page = wire(pages)->get("path=$internal"); //TODO: Error handling and logging if (!IsNullPage($page)) { $page->setOutputFormatting(false); $page->title = $title; $page->seo_title = $meta; $page->seo_description = $desc; $page->url = $urlnew; $page->seo_canonical = $canonical; $page->image_alt = $alt; $page->seo_keywords = $keywords; $page->Save(); WriteLog("{$internal} saved"); } else { WriteLog("{$internal} NOT FOUND!"); } $row++; } while (!IsNullOrEmptyString($url));
- 6 replies
-
- $Page
- Bulk Upload
-
(and 5 more)
Tagged with:
-
In the API section of PW website I found a comment made by Apeisa. He wrote: // If the page is editable, then output a link that takes us straight to the page edit screen: if($page->editable()) { echo "Edit"; } I'd like to use this function but the code shown above won't print a link - just a static string. How to edit this so the output would be a link leading to the exact page edit screen in admin control panel? Thanks. PS. Link to the page where I found the comment: http://processwire.com/api/variables/page/
- 2 replies
-
- editable()
- $page
-
(and 2 more)
Tagged with:
-
So we have a project setup that has added a module that uses the addHookAfter('save') functionality. Essentially the goal is after a we actually "Save" the page options in the backend of PW we grab specific fields we have created and do an API call to an email service which includes doing a $page->render() to grab the full html for the page we are editing and send that along as the body of that email. The issue I am seeing when I actually view the page via the browser there are images that are showing correctly from a loop of articles but when I do the render I am only getting the path to the image like for example if the image url is: /site/assets/files/2123/feature_car.jpg I am only getting via the $page->render() instead of the full path: /site/assets/files/2123/ The section that this is happening is running a loop on articles inside of the template file and is causing the error is similar to this. The problem is happening with this part of the code: <?php echo base_url().$a->featured_image->url; ?> Heres the overall code: <?php $related_articles = $pages->get(1007)->children("template=article,is_national=1,related_edition={$pages->get(1021)->related_edition},related_categories!={$pages->get(1132)},sort=-date,include=all"); if ($related_articles->count()) { foreach ($related_articles as $a) { ?> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <td> <a href="<?php echo base_url().$a->url; ?>" title="Learn More: <?php echo $a->title; ?>" target="_blank"><?php echo ($a->headline != '') ? $a->getUnformatted("headline") : $a->title; ?></a> <?php $suffix = ' <a href="'.base_url().$a->url.'" target="_blank" style="text-decoration: none;" title="Learn More: '.$a->get->title.'">Learn More »</a>'; if ($a->featured_image) { ?> <table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-bottom: 10px;"> <tr> <td> <?php if ($a->featured_image->url->description != '') { ?> <a href="<?php echo $a->featured_image->url->description; ?>" title="<?php echo $a->get('headline|title'); ?>"><img src="<?php echo base_url().$a->featured_image->url; ?>" alt="<?php echo $a->get('headline|title'); ?>" border="0" /></a> <?php } else { ?> <img src="<?php echo base_url().$a->featured_image->url; ?>" alt="<?php echo $a->get('headline|title'); ?>" border="0" /> <?php } ?> </td> <td valign="top"><p style="font-family: Arial, sans-serif; font-size: 13px; color: #555555; line-height: 16px; margin-top: 0; margin-bottom: 10px;"><?php echo (trim($a->summary)) ? $a->summary.$suffix : truncate($a->body, 250, '..'.$suffix); ?></p></td> </tr> </table> <?php } else { ?> <p style="font-family: Arial, sans-serif; font-size: 13px; color: #555555; line-height: 16px; margin-top: 0; margin-bottom: 10px;"><?php echo (trim($a->summary)) ? $a->summary.$suffix : truncate($a->body, 250, '..'.$suffix); ?></p> <?php } ?> </td> </tr> </table> <?php } } ?>