Jump to content

apeisa

Moderators
  • Posts

    4,631
  • Joined

  • Last visited

  • Days Won

    53

Community Answers

  1. apeisa's post in Show/hide content based on user was marked as the answer   
    I would use permissions or take a shurtcut and use roles for that. The shortest route is to use user, but I think it is messy even in your situation, since you have at least two users that can see the content ("user X or Y").
    - So first create (and publish) new permission, lets call it "view-hidden"
    - Create new role (or use existing role) and add the new permission to all roles that should be able to view hidden content
    - Now make sure that user X and Y have roles that have "view-hidden" permission
    Then on your template code:
    if ($user->hasPermission("view-hidden")) { echo "This is hidden content block"; } If you took the shortcut with using roles directly, then it would be:
    if ($user->hasRole("admin")) { echo "This is hidden content block"; }
  2. apeisa's post in Can't remove system field from template was marked as the answer   
    Set $config->advanced = true and whole new (and dangerous) world opens.
  3. apeisa's post in Can't echo out page title (="$") on frontend was marked as the answer   
    $item->price_currency returns page id like it should. $item->price_currency->title should give you what you are after.
    If these don't work, then make sure you have single page reference for the field price_currency. If this $item->price_currency->first()->title works, then your field returns multiple pages (PageArray).
  4. apeisa's post in Separate "page-publish" authorization was marked as the answer   
    Yep, pw has this supported. Just create permission called page-publish and then that is required.
  5. apeisa's post in PageTable and search was marked as the answer   
    You would need cache field per template. If your "parent" template and PageTable template has same searchable fields, then you would be good with one cache field. Although I am not sure if one field would go in either way (if it just skips the fields that are not interested template then one field works).
    Anyway, both of your templates need cache field attached, selector could be something like "(cachefield%=$q), (PageTable.cachefield%=$q)".
    Parenthesis make it Or selector, so it would be enough either of selectors match, no need for both to match.
  6. apeisa's post in Automatic Page Name Skipping Add New Step was marked as the answer   
    On the 2.4 dev branch:
    1. Edit template
    2. Go to family tab
    3. Choose single (1) template as Allowed template(s) for children
    4. New section becomes visibly on the same Family tab, called "Name format for children"

    No modules needed.
  7. apeisa's post in Create User That Can Add Pages But Not Edit Users/roles/permissions? was marked as the answer   
    Create new role, let's call it "editor"
    Add editor role these permissions:
    page-edit page-delete page-move page-sort page-template Hint: don't give "user-admin" role.
    Publish role and then go into templates => home => access (tab) => check edit, create and add children checboxes for editor role.
    That should be it.
  8. apeisa's post in Page field in PageTable was marked as the answer   
    architect.title
  9. apeisa's post in login problems ... all users was marked as the answer   
    Also make sure that /site/assets/sessions/ dir is writeable.
  10. apeisa's post in InputfieldDatetime / Datepicker - First ay Monday was marked as the answer   
    It's possible to localize with language support. Just translate the file InputfieldDatetime.module (if I remember right) and there is option for translation (also affects the first day of the week).
  11. apeisa's post in PageArray field, and loading template is slow was marked as the answer   
    Just change select box to PageAutocomplete or Pagelistmultiple inputfield and you are good to go. 20000 items is heavy to generate on server side and just insane for browser / ui to render.
  12. apeisa's post in Relational metadata (repeater with page fields inside?) was marked as the answer   
    Yes, they can. Actually the exact case what you described is absolutely best use cases for repeaters. Having only few fields (and mainly page fields) keep repeater UI simple and end result is very powerful.
    I just build something very similar, works great.
  13. apeisa's post in Adding child pages creates loop was marked as the answer   
    you are probably hooking into page save (you left the actual hook away from code). When you create new page, then it is also saved and hook gets repeated.

    Simple way of preventing is adding runtime property to your new page:

    $calendar->skip = true;

    and check for that property before creating new page.
    EDIT: I see you have template check there that should do the same - but it has a bug in it:
    if($page->template = 'group') should be with ==
  14. apeisa's post in Page and Page referenced was marked as the answer   
    I assume you have page field called "subjects" on your student template.
    Then the selector would be this:
    $studentsStudyingThisSubject = $pages->find("template=student, subjects=$page"); Above code works if you have that code in your subject_template. Then the $page object will have the subject you are looking for.
    Hope this helps.
  15. apeisa's post in Thousands of pages - One site with multiple pages or One install with multiple sites? was marked as the answer   
    exactly. if your need is to have shared template with custom CSS, then it is small adjustment to above scenario.
  16. apeisa's post in How do I install the CMS on its own folder? was marked as the answer   
    Moving PW installation is dead simple: copy everything (also hidden files) from /cms/ to one folder up.
    Of course you can also go to manage your apache and change where your webroot is, but I think copying the folder is easier way to go.
  17. apeisa's post in ID-based slug instead of title was marked as the answer   
    since you are using api already, try this right after your save:
    $p->name = $p->id;
    $p->save();
  18. apeisa's post in How do I loop through a sliced array? was marked as the answer   
    $articles = $pages->find("parent=/news/, limit=18"); $out = ''; foreach ($articles as $key => $article) { if ($key == 0) $out .= "<div class='slide first'>"; // Open the first .slide else if ($key % 3 == 0) $out .= "</div><div class='slide'>"; // Close the previous slide and open next $out .= "<div class='post'><h2>$article->title</h2></div>"; // render the actual markup } $out .= "</div>"; // Close the final .slide echo $out; not tested and written in browser. You can omit the limit if you want to.
  19. apeisa's post in Passing Image Field URL to CSS was marked as the answer   
    That solution doesn't scale, if client adds new page each day...
    I would add new image field called background image, set it to have only one image and then add this to template file:
    <style>
    body {
    background: url(<?= $page->background_image->url ?>;
    }
    </style>
    (written in mobile)
×
×
  • Create New...