Jump to content

owzim

PW-Moderators
  • Posts

    490
  • Joined

  • Last visited

  • Days Won

    4

Community Answers

  1. owzim's post in special character to select all records was marked as the answer   
    Why the not list the users without the region selector?
    $users->find("template=user, include=all"); Or if you want to display all users that have a region assigned (matching users with a non-empty user_region field):
    $users->find("template=user, user_region!='', include=all");
  2. owzim's post in Recommended module / solution for displaying syntax highlighted code? was marked as the answer   
    Just have a plain text field, put in your code and let the front end handle the highlighting.
    Two of the more popular solutions out there: http://prismjs.com/ or https://highlightjs.org/
  3. owzim's post in Role is NullPage although present was marked as the answer   
    I was trying to prevent a new creation of the role via:
    if(!$role = $this->roles->get('some-role')) { $role = new Role(); $role->name = 'some-role'; $role->save(); } But $this->roles->get returns a NullPage instead of null. $this->fieldgroups->get, $this->templates->get and $this->fields->get return null when not present.
    So in this case:
    $role = $this->roles->get('some-role'); if(!$role || $role instanceof NullPage) { $role = new Role(); $role->name = 'some-role'; $role->save(); } fixed it.
    I think all collection like classes should either return null or NullPage and not mixed results, right?
  4. owzim's post in Attaching iteration number to foreach-generated HTML-tags. was marked as the answer   
    OK if you really need the same iterators from the accordion, you might also iterate on your area page as well to get the same index as in the accordion:
    $i = 0; $iteratorInList = -1; // set the default -1 if not in list // "/areas/" being the url to the parent of your areas foreach ($pages->get("/areas/")->children as $area) { // find out if current page in loop is the same as current $page if($area == $page) { $iteratorInList = $i; break; } $i++; } echo $iteratorInList; Seems a bit cumbersome, but I don't know of a method like $somePage->index($list) ... similar to jQuery.
×
×
  • Create New...