Jump to content

Sebii

Members
  • Posts

    34
  • Joined

  • Last visited

Posts posted by Sebii

  1. How is it possible to check if a page is viewable to specific role (guest)? Need this to build a proper sitemap.xml.

    Hi, as the user can have multiple roles, I think you should not check it against a specific role.

    For dynamic sitemap, $page->viewable() should do it. Telling you if the current user is able to see this page.

    Or using $user->hasPermission($permission, $page) in case you want to check it from a user other then the current one.

    Edit: In case you want to do the whole selection of pages from a specific users perspective, I think this should work (untested):

    $currentUser = $user;
    $tempUser = $users->get('guest');
    $users->setCurrentUser($tempUser); 
    
    //do your page selection
    
    $users->setCurrentUser($currentUser); 
    
    
  2. Hi, from technical point I don't see much of a problem for both solutions, however the UserSelect within the pages might need some additional logic to make sure, a user is not selected in multiple pages.

    I think this question should rather go to the Client to confirm which way they intent to work. (Do they rather want to manage the users per page or do they want to manage page per user?)

    In extend, with some hooks and some magic it should also be not too hard to implement a combination of both, make it possible to manage it in both, the pages and the user.

  3. When editing the pages (homepage and one of the not-working sub pages), you can go to the "Settings" tab and verify under
    "Who can access this page?" that the access settings are done right and inherited properly.

    It should show for both, that at least "guest(everyone)" can "VIEW" the pages.

    Other then that... I'm out of idea.
    Could you maybe explain what happens exactly when logged out? You just receive a blank page, or are prompted to login, or smth. else?

  4. As Ivan suggested, did you check if your pages are in "Published" state? (Edit a page and see if you have the Publish button)

    Other causes could be that you installed a modul that prevents from "guests" to visit any page like the maintenance mode or protected mode modules?

    Also check if your templates have the correct rights set, so that the guest user is generally allowed to view the template's pages.

    Hope this helps.

  5. Hi,

    in general, processwire has a very clean an "simple" API. So it has a very easy learning curve and you get result right away.

    I think after you got the basics of PHP it is very helpful if you just start working with it(and PW). The documentation has so many examples and codesnippets that lots of stuff can really be learned by just doing it. And the more you struggle with a specific problem, the easier it should also be for you to dig into more specific tutorials that help you advance with it.

    Also the community here is very helpful and friendly and even answering some rather basic PHP questions if they come up from time to time.

    Ok, enough written, here is also a link of nice page that might help you proceed in writing good php code: www.phptherightway.com

    Hope this helps you a bit to go on :)

    Greetings

    • Like 1
  6. You have to place a new CSS file with the overwriting rule in this modules "dynamic script & styles folder" (The new CSS you meantioned in your post).
    In the configuration screen of the module, you can now select for which Processes these scripts &styles (your new css file) should be included/added to the rendering of the admin page.
    I'm not 100% sure how the Process is named that you are looking for, but I guess smth like ProcessPageTree or similar is what you need to activate it for.

    Edit: Actually it should be the ProcessPageList.

  7. That's not necessarily what I meant. Your solution should work too, but I think you don't need to do this extra copying.

    $items = $pages->find("template=product, title|body|options.title*=$freetext); 
    

    E.g. if the user searched red, you can search within the fields of the product itself (e.g. title and body), aswell as in the fields of pages from the pageselector (e.g. options.title).
    This should be what you are looking for or did I miss something?

    What I meant regarding usage of 3rd party search is mainly regarding typos, result preview text and similar things that are offered e.g. when searching with google and co.

    • Like 2
  8. Hi, I always find searching a tricky topic. Depending on the requirements you might even want to consider using a 3rd party search engine for much better results.

    However, if you have a clear page structure and you only want to search a specific field in a page selector field. You should be able to just use it like this for example:

    $items = $pages->find("template=product, options.title*='red'"); //assuming "options" is the page selector field and you want to search the title
    

    And even if it is more complex you might consider using sub-selector or (since 3.x) even nested selectors as described here: https://processwire.com/api/selectors/#sub-selectors

    I hope this helps

  9. Hi, unfortunately, I don't have experience with the user template change. But I assume you followed the description of Ryan from here: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/ ? Maybe you can make sure that everything was configured as described, especially the site/config.php part. Also in the hope that everything stayed like that in 3.x :)

    However I also had this redirect problem under other circumstances, where a Page could not be created but the error was not properly handled in the code.

    Did you check the log files, maybe they give you a hint on the error/problem that is happening here?

  10. The whole module should be in /site/modules/ to begin with. You don't install modules into /wire/modules/ - that is only for the core modules.

    I think the mentioned change it not part of the discussed module, but really a change of a core module. So that's not the problem.

    @ottogal: You can try to use the AdminCustomFiles module (https://processwire.com/talk/topic/7588-admin-custom-files/) and just place a CSS file that overwrites this rule as you mentioned in your post already.

    This should work if I'm not overlooking smth.

    • Like 3
  11. Hi sorry, it looked like it is already coming from a different imagefield.

    foreach($product->image as $image) {
      $pageimage = new PageImage($page->images, $image->url); 
      $pageimage->tags = "tag1 tag2";
      $page->images->add($pageimage);
    }
    

    Edit: Woops, too slow and too much fiddeling. See the answer above... :)

    • Like 1
  12. Hi, if I'm not mistaking, the tags are added to the image:

    # upload images
    foreach($product->image as $image) {
      $image->tags = "tag1 tag2";
      $page->images->add($image); //assuming $image is already a PageImage?
    }
    

    The imagefield itself can only be used to query the tags of the images then:

    //e.g.
    $page->images->findTag('tag1');    
    

    Hope this helps

  13. Hi, for a very common task like SEO, it might be also worth to:
    1) Make use of the fields import/export to share the set of SEO fields betweend pw installations
    2) Add the SEO fields with a small custom script making use of the API

    An example of it can be found on processwire-recipes.com

    Greetings

    Edit: Link :)http://processwire-recipes.com/recipes/add-fields-to-template/
    Edit2: Or actually just create the whole set of your SEO fields (+adding them to templates) in a reusable script

    • Like 5
  14. Hi thanks for that hint. I can only try it out later.

    For feniks, this might not help as I understood, as he needs the page before it is trashed, but maybe it could work if you change your hook method (test above) with a check if the page is trashed? If there are really two different calls like Soma suggested, it should be one before actually trashed and in the second call of the modified page before save(?).
    Maybe you get to try it out before me:

    $page = $event->arguments('page');
    if($page->isTrash()) return; //should only happen on the second call(?)
    

    However I did not fully understand your use-case fully. Depending on what you want, it might be much easier to just count the children where you need them in Parent(1) or if you know the parent(s) you want the count for, you could also do it easier I guess:

    // e.g. just:
    $page->numChildren;
    // in the template, or outside e.g:
    $pages->count("has_parent=/locationOf/Parent");
    

    Hope this helps.

  15. Hi,

    if I'm not mistaking, you can check if a specific option is selected using the has() method.

    So in your case one of these options should work:

    if ($page->portfolio_type->has(1)) { ... }  //assuming the option is defined as: "1=A Project"
    if ($page->portfolio_type->has("title='A Project'")) { ... }

    Hope this helps.

    Edit: Background should be that the option field returns a WireArray. Which has the has() method for checking its content.

    • Like 4
  16. Yes right, it's not even in your code... My fault, sorry.

    Did you make sure all caches are emptied (if applicable) and also disabled the cache of the page's template?

    What you maybe also could take a closer look at is the cat_rank (?) field which seems to be involved too. 

    Maybe check the field and it's option values etc. maybe something changed or is wrong there?

    Hope it helps

    • Like 1
  17. Hi, looking at the error message at:
     

     DatabaseQuerySelectFulltext->match('fieldtype_optio...', 'title', '>', '0 ')
    

    It looks like you use a selector like "title > 0". That might be the issue, as a text field does not support the "> or <" operator. (Assuming that your title is a text field, not integer).

    Maybe check where this selector is used and replace it with a proper one.

    Greetings

  18. Hi, if you define your buttons in a generic way from your dashboard template like:
     

    <button class="pwbutton" data-pid="123" data-change="publish"...>
    <button class="pwbutton" data-pid="123" data-change="unpublish"...>
    <button class="pwbutton" data-pid="456" data-change="publish"...>   
    

    Then you should be able to handle the ajax as follows (untested):

    $('.pwbutton').click(function(){
        $.get( '/change-status', { pid: $(this).data('pid'), change: $(this).data('change') }, function() {
                            alert( "success" ); //e.g. update page status on dashboard
                    }).fail(function() {
                            alert( "error" );  //e.g. error message
                    });
    });
    

    Ideally the /change-status template should be aware of the ajax request and respone with infromation you need to update your dashboard accordingly.

    Hope this helps to get you started. Maybe also take a look at the jQuery documentation to understand whats happening: jQuery.click()  jQuery.get()

    Greetings

    • Like 3
  19. Hi,

    I could reproduce this in current dev 3.0.16. .   Pages::trash seems to be executed twice.
    Is this still up to date for you? Maybe anyone else has a hint on what is wrong with it?

    Greetings

×
×
  • Create New...