Jump to content

nickngqs

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by nickngqs

  1. I just found out the issue filemtime doesn't resolve the path of 

    $config->paths->assets . 'js/script.js'

    You will need to use $_SERVER["DOCUMENT_ROOT"] to get the root of your server. So the line should be something like this 

    filemtime($_SERVER["DOCUMENT_ROOT"] . $config->paths->assets . 'js/script.js');

    Hope this helps anyone

  2. On 3/29/2018 at 5:36 AM, gRegor said:

    I've done a simple version of this by hashing the file's modified time:

    
    $js_version = md5(filemtime($config->paths->assets . 'js/script.js'));
    echo sprintf('<script src="%sjs/script.js?v=%s"></script>', $config->urls->assets, $js_version);

     

    How do you wipe the cache or something.
    When i do the filemtime, it doesn't detect the new modified time, it always produce the same $js_version string.
    I've tried clearstatecache() but to no avail, it's always producing the same $js_version string.

  3. 9 minutes ago, kongondo said:

    You cannot post to nothing :). You have to post your client-request to something server-side to handle that request. That something can be a module page or a 'normal' (hidden, in admin, etc) page.

    A URL Segment alone won't work. The name gives it away. Segment of a URL. A URL points somewhere. In ProcessWire, it points to a page. So, yes, you will need a page somewhere in the system.

    Yes, I'm awared of that. In normal setup, in a non Processwire website. I'll just put a add_client.php in a folder, and form post to that add_client.php which will provide that server-side handling for that request.

    But the issue I'm getting is that since Processwire routes everything according to the pages you've created. How can I route that url to add_client.php file without creating a page.

    Currently, my work around is creating a page called add_client.php

    I'm just curious if there's a better way to do this.

  4. 3 minutes ago, Sergio said:

    Yes, you can use the database class: https://processwire.com/api/ref/database/

    You can create a module (recommended) or do it directly on your template. See this example:

    
    public function saveViews(Page $page)
        {
            $db = $this->wire('database');
            $table = "table-name";
    
            $sql = "SELECT page_id, COUNT(page_id) as total_views
                    FROM $table
                    WHERE page_id=:page_id";
    
            $query = $db->prepare($sql);
            $query->bindValue(':page_id', $page->id, \PDO::PARAM_INT);
    
            try {
                $query->execute();
    
                while ($set = $query->fetch(\PDO::FETCH_ASSOC)) {
                    $new_views = $set['total_views'];
                    $current_views = $page->page_views;
                    $page->setOutputFormatting(false);
                    $page->page_views = $current_views + $new_views;
                    $page->save('page_views');
                    $this->wire('log')->save("messages", $new_views.' views imported for page '.$page->title);
                }
    
            } catch(\Exception $e) {
                // intentionally blank
            }
    
            
    
        }

     

    Hi, thanks for the insight. But not, what I'm looking for. (But it does help with my later part of the stage)

    But for now, currently, when doing a <form action='add_client.php> </form>. Processwire search for pages instead. So I'll need to create a page named add_client with a add_client template to make it work. How to I ask the form to post straight to add_client.php without adding a page.
     

    10 minutes ago, Fokke said:

    Hi!

    You can use URL Segments to archieve this.

    Thanks, I'll looking into this.

  5. I'm trying to create a form that does a post to a php file, getting the values before posting to a database.


    For example a form with an action /controller/add_client.php.

    My current workaround is create a page with the add_client template. But is it possible to do that without creating a page? I.E i do not want it to show on the CMS side.

  6. Does anyone know how to do an export of a page entries to CSV using the Processwire way?

    I'm trying to setup a list where the client can see a list of user's form values.

    Example ->

    A front end form -> Upon submit -> Adds to database -> Shows on the admin of Processwire.

    From there, I can see the entries and sort stuff. And lastly I can export them in CSV.

    I'm looking at the Processwire cheatsheet and see the $files, is this the one I should be looking at? 

  7. Hi thanks! Managed to follow your tips. However, I still unable to see the tab on the masthead.

    I did managed to add the permissions and add them to my Role 'Client'. So previously, I can't access url/admin/settings. But right now I can access url/admin/settings using the permission.

    But still unable to figure out how to see the Settings tab.

    This is the superuser view
    superuser.png.7f09fb97d6db8266778127600925d6d1.png

    While the client view is
    client.png.4e4f7c8de0f7a25be8fcca924a4abe62.png

  8. How do I change the permissions for Who can access this page for a single page.

    This page inherits the admin template.

    I'm currently creating a new page called Settings using admin template and assigning it to a process of a module. I can see the Settings tab in superuser, but I can't see them in a role I defined called 'client'.

    So, how can i control what the client sees for admin template? Is there a page specific overwrites for permissions. I've tried allowing access in admin template view, edit. But still doesn't work

  9. Hi guys,

    I'm trying to wrap my head around creating dynamic blocks where the end-user can add blocks on the fly on individual pages without specifying it in the templates.

    What approach do you guys usually do? I've tried scouring the forum for solutions but seems to get abit confusing. I've read Hanna Code, Repeater Matrix, PagesTables and seen the youtube tutorials. Not sure, where to start from. I only got very minimal knowledge of php as I came from a front-end background (html, css, js)

    I'm looking to define my blocks somewhere where the end-user will not be able to see.

    For example, a simple block container

    <div class='container'>
    <div class='container__title'> {{ $title-field }} </div>
    <div class='container__image'> {{ $image-field }} </div>
    </div>


    Then maybe we got a second block container

    <div class='container-2'>
    <div class='container-2__title'> {{ $title-field }} </div>
    <div class='container-2__image'> {{ $image-field }} </div>
    </div>


    Then the end-user can just to add these blocks into any pages on the fly and re order them according to their needs. My processwire is v3 using the UIKit3 Admin if that makes any difference

    Sorry if I sounded too noob.

  10. Are they any stuffs that I can say to make them switch over from Wordpress. Almost every clients I encountered, seems to just assume Wordpress = CMS, CMS = Wordpress. At the very least in the simple informational sites (market).

    I'm trying to build a deck to convince them to use Processwire over Wordpress. If anyone got any statistics, that would be better. Since most clients won't understand the terminologies etc, it would be great to have visual stats to make them more inclined for the switch.

    For example, security wise or speed wise, is Processwire statistically better than Wordpress? Feel free to suggest any advice you guys might have when persuading your clients for the switch :D First post!

×
×
  • Create New...