Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Ah yes right, negative evals to true. So then correcting mine: if($id > 0){...} But don't see why that would be an issue to have a negative page id it won't find it anyway.
  2. If negative is a issue at all then if($id){ ... }
  3. Usually like this. $id = (int) $input->post->id; $p = $pages->get("id=$id, template=dings"); if($p->id){ // valid } else { // not valid }
  4. So this is sufficient, as in most cases in PW like fields. No isset() or empty() etc. if($session->cart_item){ .... exists or is populated } else { .... doesn't exists or is empty } You can also write, as always in PW $session->get("cart_item"); You can also use namespaced session $session->seFor("myshop", "cart_item", $cart_item); and get it with $cart_item = $session->getFor("myshop", "cart_item"); BTW what happens if hack your code and enter a "template=user, id=40, check_access=0" into your "product_id" POST?
  5. Those tools don't support multi language.
  6. https://processwire.com/talk/topic/1036-markupsimplenavigation/?p=8998 First post of this thread there's a link to an gist with an example to output bootstrap like html. But it's just an old example I worked out back then. I never used bootstrap so can't tell if it's still working with newer versions? (one of the reason I avoid frameworks )
  7. @surffun it's kinda hard to tell in general and it's so obvious that we may fail to see where you're struggling. There's tons of options in MSN to modify the output and examples are everywhere. Still don't know what the problem is you have.
  8. Any chance to update this module for 2.5+? Aka making the dev to the new master?
  9. Nothing is impossible. This is quite easy with MarkupSimpleNavigation: $tree = $modules->MarkupSimpleNavigation; $treeOptions = array( "show_root" => true, "outer_tpl" => "<ul class='main-menu cf'>||</ul>", "inner_tpl" => "<ul class='sub-menu'>||</ul>", ); $tree->addHookAfter("getItemString", null, function ($event){ $child = $event->arguments("page"); if($child->id != 1 && $child->numChildren(true)){ $itemStr = "<a href='{$child->url}'>{$child->title} <span class='drop-icon'>▼</span> <label title='Toggle Drop-down' class='drop-icon' for='tab_{$child->name}' onclick>▼</label> </a><input type='checkbox' id='tab_{$child->name}'>"; $event->return = $itemStr; } }); $menuStr = $tree->render($treeOptions); <nav id="mainMenu"> <label for='tm' id='toggle-menu' onclick>Navigation <span class='drop-icon'>▼</span></label> <input id='tm' type='checkbox'> <?php echo $menuStr;?> </nav>
  10. Which cache? Template cache you would go to the PageRender module settings and delete cache.
  11. Something using WireArray and WireData. You could use it like this, and all WireArray method would be usable like find(selector) , filter(), remove(), sort() etc. Somewhere in an autoload module or in /site/init.php <?php class MySiteConfig extends WireArray{ public function addItem($key, $value){ $item = new WireData(); $item->name = $key; $item->value = $value; $this->add($item); return $this; } public function render($key){ $str = ""; foreach($this->find("name=$key") as $d) $str .= " " . $d->value; $str = trim($str); return $str; } } // create a new "global" $siteConfig template variable $myConfig = new MySiteConfig(); $this->wire("siteConfig", $myConfig); $siteConfig would then be available everywhere. The addItem() would allow to add items to the WireArray with name -> value. In basic-page.php Template file: $siteConfig->addItem("classes", "main")->addItem("classes", "myClassX"); $siteConfig->addItem("classes", "myClassY"); $content .= wireRenderFile("blog"); then in the blog.php partial $siteConfig->addItem("classes", "blog"); ?><div class='blog <?php echo $siteConfig->render("classes"); ?>'> <h1>Blog Test</h1> <?php // example of using WireArray's implode() echo $siteConfig->implode(" ", "value"); // example of filtering items $vars = $siteConfig->find("name=classes, value^=my"); if($vars->count) { foreach($vars as $v) echo " $v->value"; } ?> </div> This would be easy to extend with further helper methods etc. Also in your template site/init.php or templates/_init.php you could create various template variables That is just a fictive example, not sure how practical this is for handling a use case mentioned in this thread.
  12. Maybe of use for someone. I somewhere use a in a Helper module's init(); // site specific configs $this->wire("config")->site = new StdClass(); // so now you can do $this->wire("config")->site->someKey = "somevalue"; and use this $config->site->someKey everywhere.
  13. CSRF doesn't work with a cached form. The PRG post rdirect get is the best design pattern to prevent double submission in case of a refresh or going back in browser.
  14. I'm not sure what you mean by "go through all pages". PW uses SQL "status &1" and it's 1 DB query and works fine. By default PW find() returns only published pages.
  15. Pocketgrid is neither a framework nor a library, it's an approach.
  16. What exactly is the problem? If you may do a redirect after form processing, the post var is lost.
  17. No, PW doesn't have to go through all pages, it's DB query. Field "published" is brand new and for timestamp of the publish date. If a page is published or not is in status and it's a bitmask.
  18. No you use $pages->find("template=basic-page, status=unpublished"); Respectively $pages->find("template=basic-page, status=published"); But since $pages->find("template=basic-page"); returns only published pages anyway that are not hidden and above, a status=published makes no sense.
  19. Thank you. I'll have a look when I get to it.
  20. $child->image->url If this only does give you the path to the folder, your image field is multiple and not a single image field. If you change your field to only allow 1 image, then this would give you the full url to the image.
  21. If you only want to allow one page you should also configure to only allow single page. Currently you have a single select but the field is multiple.
  22. Or you can use adjustName=>true option in the save.
  23. PW runs the actions not the PageAction module. It sends each item to the action().
  24. PageActions are run either in one step or if more than hundreds in batches. You could batch millions of pages without running into timeout or memory issues.
  25. Sorry there's no example CSS. Definately something I try to add. Write your CSS with using the css classes the module gives you by default. . Often not much is needed. Also you can change the class names and use various tpl options too to add your own. I mostly use the default and give the "outer_tpl" => "<ul class='main-menu'>||</ul>" as a starting point.
×
×
  • Create New...