Jump to content

arjen

Members
  • Posts

    1,222
  • Joined

  • Last visited

  • Days Won

    8

Community Answers

  1. arjen's post in Selectors sort by parent title|id was marked as the answer   
    Hi Tim,
    What is the structure of your tree? I've read your question twice, but can't seem to understand what you mean. You can sort by subfields like:
    $pages->find("template=test, sort=parent.title, sort=page_field.sort"); Perhaps that is what you are looking for?
  2. arjen's post in Checking for multiple page ids if statement not working. was marked as the answer   
    Netcarver beat me 
    An alternative:
    <?php if ($page->matches('id!=1021|1105')) { echo 'do stuff'; }
  3. arjen's post in Markdown/Parsedown with Hanna Code was marked as the answer   
    Your markup doesn't seem like proper Markdown formatted. 
    # Image ![Alt description here](http://plauclair.me/site/assets/files/1772/logo_processwire-1.421x0-is-hidpi.png) Also be sure to have the Markdown module installed and assigned/applied to the field.
  4. arjen's post in Developer and public site simultanously was marked as the answer   
    Also look into the template switch based on your subdomain by Raymond.
  5. arjen's post in Loading sub-template content using AJAX was marked as the answer   
    You can halt() like this:
    <?php if ($config->ajax) { // Do your stuff here echo 'Heard It Through The Grapevine'; // Call halt() to prevent further loading return $this->halt(); }
  6. arjen's post in Cant publish role was marked as the answer   
    What if you disable the config module and just use the /site/config.php? Have you entered the domains in both?
    Also, you might want to check if ProcessWire (or PHP) is able to get the proper hostname. I had one case (on a shady server, long time ago) where PHP didn't recieve the proper hostname so ProcessWire kept telling me that I needed to update the hostname.
  7. arjen's post in Admin lag was marked as the answer   
    You might want to try to set the the dbHost in /site/config.php to:
    $config->dbHost = '127.0.0.1'; // Use an IP address instead of localhost Also on Mac don't use .local domains like mywebsite.local. This can be very slow due to some internal routing stuff. 
    There are others too with slow admins. Small hint 
  8. arjen's post in Group fields in tabs? was marked as the answer   
    The ability to add tabs not specific to ProDrafts.
    Create a new field called "sidebar" with the type FieldsetTabOpen. ProcessWire will automatically add another field "sidebar_end". Go to a template and add those fields. Add some fields between sidebar and sidebar_open and you will have a tab for that specific template. You can also group fields with FieldsetOpen. 
  9. arjen's post in Add wrapClass to Inputfield in admin was marked as the answer   
    After doing some testing it turns out that when a user doesn't have access to edit a field the classed were not added since there is no Inputfield to render. Better solution:
    wire()->addHookBefore('InputfieldWrapper::render', function($event) { $wrapper = $event->object; foreach ($wrapper->getChildren() as $f) { // Only fieldtypes can have tags && make sure the fieldtype has tags if ($f->hasFieldtype && !empty(wire('fields')->get($f->name)->tags)) { $f->set('wrapClass', "tag-" . wire('fields')->get($f->name)->tags); } } });
  10. arjen's post in How to set variables bases on user actions? was marked as the answer   
    No problem. Checkout the following code for more insight. All written in the browser, so it's not tested. But you get the idea.


    <?php

    // Create a form using the API. You can thank soma >

    $form = $modules->get("InputfieldForm");
    $form->action = "./";
    $form->method = "post";
    $form->attr("id+name", "form");

    $field = $modules->get("InputfieldText");
    $field->label = "Name";
    $field->attr("id+name", "name");
    $field->required = 1;
    $form->append($field);

    $field = $modules->get("InputfieldHidden"); // A hidden field to populate which product should be stored in the session
    $field->attr("id+name", "product");
    $field->attr("value", $product->id); // You can use the value (i.e. $product->id) to save the data
    $field->required = 1;
    $form->append($field);

    $submit = $modules->get("InputfieldSubmit");
    $submit->attr("value", "Subscribe");
    $submit->attr("id+name", "submit");
    $form->append($submit);

    if($input->post->submit) {

    $form->processInput($input->post);

    if($form->getErrors()) {

    $out .= $form->render();

    } else {

    // Always sanitize user data
    $name = $sanitizer->text($input->post->name);
    $product = $sanitizer->text($input->post->product);

    $session->name = $name; // Using $session->name you can get this data back on another page
    $product->product = $product; // Idem dito

    $session->redirect($pages->get("PAGE_ID")->url); // The page (PAGE_ID) you want to send the user to (i.e. the checkout page)

    }
    } else {

    $out .= $form->render();

    }
  11. arjen's post in role permissions was marked as the answer   
    Depending on your ProcessWire version, you have to enable the access on template (system template: user) level as well.
  12. arjen's post in New 2.5 site launch 500 error was marked as the answer   
    I think your PHP version is not sufficient enough. It need to be > 5.3.8.
  13. arjen's post in Login/Password-reset Problem was marked as the answer   
    Are you absolutely sure your superuser is called admin? I think you can verify that in the database.
    Another option is creating a new superuser:
    $u = new User(); $u->name = "therealsuperuser"; $u->pass = "therealsuperuser123"; $u->addRole("superuser"); $u->addRole("guest"); // Don't know if this really is required $u->save();
  14. arjen's post in Question about multi language was marked as the answer   
    $out = $this->_("Live long and prosper"); // syntax within a class $out = __("Live long and prosper!"); // syntax outside of a class All the information you need is right here in the docs.
  15. arjen's post in Multiple page update problem - missing something obvious was marked as the answer   
    Try:
    $lev->save();
  16. arjen's post in Excluding child pages from menu was marked as the answer   
    There are several options:
    Check if the $p has a specific template (or any other field).
    if(count($children) > 0 && $p->is("template!=news-item|other|template")) Or exclude above the loop like:
    $children = $p->children->not("template=news-item|other|template"); Or filter above the loop like:
    $children = $p->children->filter("template!=news-item|other|template"); See the excellent cheatsheet for more options in the PageArray/WireArray. Another option might be to use to use soma's navigation module.
  17. arjen's post in Form-Builder gives a 404 after going live was marked as the answer   
    Can we see the error somewhere? What version of PW and FB are you using? Perhaps you should change the httpHosts array in your config.php file:
    $config->httpHosts = array('localhost', 'example.com', 'www.example.com');
  18. arjen's post in Selector find page reference - help was marked as the answer   
    team_name=$page I always match the field against the object instead of the id.
  19. arjen's post in Fatal error: Exception: Invalid type to Pageimages::remove(item) was marked as the answer   
    I think your } on the third line isn't supposed to be there. The foreach is getting called every time. I think you might want something like this:
    if (count($page->image) > 1) { $first = $page->image->first; echo "<h4>$page->title</h4>"; foreach($page->image->remove($first) as $img) { if ($img) { echo "<img src='{$img->url}' />"; } } }
  20. arjen's post in Get page title based on page id was marked as the answer   
    What ID are you getting when you echo $pages->get($cityid)? You might want to wrap into quotes like $pages->get("$cityid").
  21. arjen's post in Different logo on different language was marked as the answer   
    <img src="logo-<?php echo $user->language->name; ?>.png" alt="" /> This will give you the name of the language. So you either make sure you change the language name or the filename of the images to make sure they match.
  22. arjen's post in Template not allowed in page setting was marked as the answer   
    Good to hear. You might want to mark this thread as solved
  23. arjen's post in Repeater - item collapsed was marked as the answer   
    You're right apeisa, but soma did come up with a sort of solution.
  24. arjen's post in Verifying user permissions for each page was marked as the answer   
    if ($page->user->has($user)) { // Do stuff } Not tested, but something like this would work since the "user" fields returns a array which you can check all kinds of thing in. See the cheatsheet for more info.
  25. arjen's post in Sort by parent, then by title was marked as the answer   
    I guess this will work:
    $pages->find("template=individual, sort=parent.title, sort=title"); $pages->find("template=individual, sort=parent, sort=title");
×
×
  • Create New...