Jump to content

VeiJari

Members
  • Posts

    63
  • Joined

  • Last visited

Posts posted by VeiJari

  1. Hello forum, we're trying to use Processwire as our REST-API. We are having problems with our API login to Processwire from frontend. It gives us 403 error.

    We have installed ProcessWire to subdirectory (/api/*) and our frontend is static JS files at root ( / ). Apache access logs gives 404 to our POST-request, but browser devtools shows 403 for our POST /api/login request. 

    Processwire backend panel works. We also have a GET endpoint for the API that returns 200 with correct payload.  So we're wondering why does our GET works but POST doesn't?

    Does this have something to do with Processwire .htaccess, or is this because of our webhost? What should we check first? Any help would be appreciated.

  2. 13 hours ago, adrian said:

    @VeiJari - you already have the option in your code above:

    
    'namesFirstRow' => true,

    That will add the field names to the first row. If you want labels instead, then that would be a new option I would need to add.

    However, I did find a couple of bugs when exporting via the API which I have fixed, so please update to the latest version.

     

    I didn't do anything other than upgrade the Table module (and also the PW core) like I mentioned above.

    @adrian I changed the names of the field now, but It would be nice to implement an option to import the actual labels of the fields, this way we get more tidy up exports for our customers and end-users.

  3. 14 hours ago, adrian said:

    Hi @VeiJari - are you referring to table subfield labels vs names? Names can already be added to the header row with the poorly-named "Column labels" option. Does this do what you need, or do you want an option for the actual Label instead of the Name?

     

    Hi, I would like to test this option, but I didn't found a way to implement it in the code, could you give me an simple example of this?

  4. 2 hours ago, adrian said:

    Looks like the OR selector you were trying to use is now working in the latest version v20 that Ryan posted in the PF download thread. Note that this is actually "0.2.0" - I have never understood why he is inconsistent with those version numbers like that ?

    There are also changes to the PW core around this issue, so you should probably update to the very latest dev commit, although I actually found that what you were trying to do worked before I did that update.

    Hey how did you get it working exactly?

    Thanks a bunch for your helpful advices!

  5. On 12/4/2020 at 7:38 PM, adrian said:

    Hi @VeiJari - this isn't an issue with this module, but rather the selector system for the Table field. You can test that yourself with the Tracy console:

    
    d($page->log_usage_table('pr_location=1025|1027'));

    and you'll see the same problem. So, I think this is a question for Ryan. Here is a discussion about OR selectors in Table (https://processwire.com/talk/topic/24508-what-is-it-with-profields-table-and-or-selectors/), but it's not specific to Page Reference subfields so you'll need to bring that up specifically.

    @adrian Hey, I see. I'll wait for the next version then. Follow up question: Is there a way to get the labels for the table fields to the exported CSV?

  6. Hey @adrian, I'll start of by saying thanks for this module!

    I have a slight problem with it though. I'm trying to filter results to the csv export by page references with their ids with the selector option:

     $modules->get('ProcessTableCsvExport'); // load module
        $options = array(
            'delimiter' => ',',
            'enclosure' => '"',
            'extension' => 'csv',
            'multipleValuesSeparator' => ' | ',
            'namesFirstRow' => true,
            'columns' => array('sessiontoken', 'logintime', 'pr_ticket.title', 'pr_location.title', 'pr_exhibition.title'), // columns to export can be index starting at 1, or column names
            //'selector' => 'pr_location=1025|1027', this doesn't find anything
            'selector' => 'logintime>= ' . $dateStart . ',loginTime<=' . $dateEnd . ',pr_ticket=' . $selectorTicketIds . ',pr_location=' . $selectorProvidersIds,
        );
     
        try {
            $page->exportTableCsv('log_usage_table', $options);
        } catch (exception $e) {
            $log->message('Virhe viennissä' . $e);
        }

    If I use 'selector' => 'pr_location=1025', it works fine. So I suspect the OR selector doesn't work. Is there way to circumvent this or what should I do?

    Thanks for the help in advance!

  7. @kongondo

    Hey I have a pagereference array added to user template.

    I'm trying to add multiple pages to it via api. I have all the page ids to add as an array.

    I can't add multiple pages to the page reference array. I've tried with: 

    $userToCreate->projectReferences->add(wire()->pages->find('id=' . implode ('|', $data->projects), ['findAll' => true]));
    $userToCreate->projectReferences = wire()->pages->find('id=' . implode ('|', $data->projects), ['findAll' => true]));
    //however this works
    $userToCreate->organisationReference = wire()->pages->get('id=' . $data->organisationId, ['findOne' => true]);

    I'm adding 'findAll' because of my custom authentication for templates. And using wire() because this doesn't happen in a template file

    How I can add multiple pages to this pagereference array?

    Thanks for your help!

  8. Hello,

    I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array.

    Code: 

    $dataUsers = $data->project->users;
      foreach($dataUsers as $dataUser) {
        $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id));
      }

    I'm receiving my data via JSON.

    Is there something I'm missing?

    Thanks for help

  9. On 9/18/2020 at 12:52 PM, Ivan Gretsky said:

    If it is only one project per user, you could use this module. If you need to grant a user access to 2 or more branches, you probably need to hide the tree of pages to that user and display accessible pages with a custom module.

    I hope I understood your question properly)

    I want to achieve that you can give a as many projects you want to a user. But that in $pages->find() the user should see only the pageobjects it has permissions to. I've tried to find how Processwire checks page specific access, but I haven't found it yet. I've tried with $permissions->get() but I only get nullpages, and not the page I've given it access to in the module.

     

    I'll keep looking for it in the API-documentation.

    Thanks for the help anyway, if you know what API-call I should use, It would be nice.

  10. Hi, this is the first we are trying to make a page that has only one type of user that has access to every page. 

    The other users should only have a given access to specific pages, not to the whole template.

    My structure

    -Field
     -Organisation
    	-Project
    		-Report

    I want that the "measurer" role only has access to "project x" and it's children, but no view access to every project, organisation or field. I've tried to do this with https://modules.processwire.com/modules/page-edit-per-user/ but it still needs a view access to the whole tree to see the "project x" page. Or is there something I haven't figured out?

    Maybe I have to make it via the API: a select field in the "organisation" template where the admins could add the users and then I use hook to update the privileges?

    Have you done something like this and how did you accomplish it?

    Any help would be appreciated.

     

  11. @Wanze Thank you for this awesome module!

    We noticed a small bug on 1.0.0 version, we can't use scandic letters (Ä, Ö, Å).

    This works on version 0.9.0.

     

    This has something to do with UTF-8 encoding not enabled on 1.0.0?

  12. Hello forum,

    This is really a weird one, because front end editing works in a earlier website we did to a customer. 

    When I check the source code for current website it does initiate front end edit: 

    <span id=pw-edit-1 class='pw-edit pw-edit-InputfieldPageTitle' data-name=title data-page=1021 data-lang='1017' style='position:relative'><span 	class=pw-edit-orig>Tekijät</span><span class=pw-edit-copy id=pw-editor-title-1021 style='display:none;-webkit-user-select:text;user-	select:text;' contenteditable>Tekijät</span></span>

     But when I double click nothing happens (yes I'm 100% sure I'm superuser and logged in)

    I also tried to apply the front end with other methods than:

    $page->edit('title');

    But didn't work either.

    We are using jquery 2.2.4, so it should not be a problem.

    Is this a bug related to current master or something else?

    Someone else having this problem as well?

  13. Hi,

    Our problem is that we're making the map marker template from another template via page reference. We've tried to add our own checkbox "show map" but it has proven quite difficult to follow the geotag ON/OFF logic.

    I would love to see if someone has figured this out.

    TLDR

    is there anyway for checking if the map is enabled, or do I have to make my own checkbox logic for it

     

  14. 11 hours ago, teppo said:

    Hey @VeiJari,

    This should be doable by either hooking into the Renderer::renderResults() method and replacing it with custom method of your own (that doesn't contain the path), or simply by setting the result_path template string to an empty string or null via config options:

    
    $config->SearchEngine = [
        'render_args' => [
            'templates' => [
                'result_path' => '',
            ],
        ],
    ];

    Let me know if this doesn't work, though ?

    Works, thank you for the quick response yet again! :)

    • Like 1
  15. @teppo

    Hey, is there a way to exclude the path from the summary results?

    I've added a custom config table and I've managed to change the "summary" field to our corresponding one.

    But I couldn't find a way to exclude 'result_path' in renderer.php on line 204. (other than just comment it out)

    Is this something that needs to be added? Or is there a trick to it?

     

  16. On 8/8/2019 at 4:59 PM, dragan said:

    Where? In the frontend or backend?

    If you're doing forms in the frontend, you have to write your own validation logic.

    Or do you refer to field dependencies in the backend ("required only if...") ?

    And another clarification whan I mean by an error, if you make a field required in the backend, it prompts an error above the field ('this field is required"), this is the error I want to make from the api.

    Thank you

  17. On 8/5/2019 at 7:34 PM, teppo said:

    What you're seeing there is just what happens between browser and server, i.e. spaces getting replaced by %20. If you're echoing the value, it won't get executed as PHP code (you'd have to call eval or something similar to get that effect), but it could still allow HTML or JavaScript through – which is probably also something you don't want to allow. For an example, see what happens if you set the key value as <script>alert("hi")</script> instead.

    The general rule of thumb is to always sanitize user input ?

    That being said, if you're certain that you're only reading the GET variable and comparing it to some pre-defined value, and you'll never store or output it as-is, then there's no real harm in not sanitizing it. As you've proven yourself, it won't get evaluated as PHP code.

    Thank you, it's only to compare it to a backend field that only admin's has access to.

    I understand the basic principle now.

  18. On 8/8/2019 at 4:59 PM, dragan said:

    Where? In the frontend or backend?

    If you're doing forms in the frontend, you have to write your own validation logic.

    Or do you refer to field dependencies in the backend ("required only if...") ?

    Sorry for the confusing question. Let me clarify.

    I'm talking about how to detect if I get a session error on backend in hooks.

    Also is there a way for us to give an error considering only a inputfield in backend, instead of just getting a session error?

     

    Thanks

×
×
  • Create New...