Jump to content

psy

Members
  • Posts

    741
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by psy

  1. @prestoav I needed something similar however I did not want to give the front end users all the features available in the PW CKEditor menu. It was more difficult for me to reduce the feature set than start afresh for the front end and I chose TinyMCE over CKEditor.

    In the form, I created a textarea field with no textformatters and a limit of 5000 characters. In my template:

            <script src="<?=$config->urls->templates?>scripts/tinymce/tinymce.min.js"></script>
            <script>
                // NoMinify
                tinymce.init({
                    selector: '#Inputfield_introduction',
                    height: 300,
                    menubar: false,
                    plugins: [
                        'advlist autolink lists link image charmap print preview anchor',
                        'searchreplace visualblocks code fullscreen',
                        'insertdatetime media table paste code help wordcount'
                    ],
                    toolbar: 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',
                    setup: function(ed) {
                        var maxlength = parseInt($("#" + (ed.id)).attr("maxlength"));
                        var count = 0;
                        ed.on("keydown", function (e) {
                            count++;
                            if (count > maxlength) {
                                alert("You have reached the character limit");
                                e.stopPropagation();
                                return false;
                            }
                        })
                    }
                });
            </script>

    And the end result on the front end:

    1663469315_Screenshot2020-01-2919_17_32.thumb.png.ae6350b98c69ced54d4cc8e887a9d555.png

    Data is saved correctly in the DB and all good.

    PS: If anyone tries to add in a sneaky <script>, it throws 403 Forbidden error

     

    • Like 2
  2. Another thing I love about PW is the friendly, supportive forum. I certainly don't want to be accused of trolling the guy. He put his opinion out there based on his experiences, as is his right. Should he venture here though, I'd be more than happy to help him with his PW site

    • Like 6
  3. "You can't fix 'stupid'" is an old saying. Sure PW is not for everyone and as the guy said, "Great for developers (I assume), pretty bad for everyone else". What got up my nose was he presents himself as a web developer/designer/guru and his own site is technically bad. Done well, PW is great for everyone. I suspect where he got lost was "assuming" that PW was a load the app, apply a FE theme, bung in a few plugins, squeeze your content to fit the theme and away you go.

    The thing I love most about PW is the exact opposite. I have complete freedom to build my sites, backend, frontend & user-friendliness

    • Like 7
  4. 9 hours ago, dragan said:

    That's exactly where (the often overlooked) Pro field "Functional Fields" shines. It does exactly what you are looking for.

    I usually do a combination of both - separate 'Business Info' page that stores stuff like logo versions, etc and a functional field that stores common text phrases. All editable by admin on that page and (I believe as don't use it), editable for multi-lang sites. Even go so far sometimes to make the page a link in the admin main menu, with or without a custom module

  5. Hi @3fingers, thank you.

    As mentioned, it's not an out-of-the-box solution. Read the Dropbox API doco. Maybe:

    • Dropbox app/yourclientfolder/subfolder-by-pw-user ? Or,
    • List files in the Dropbox folder as checkbox options in the client's private page admin area- tick for each needed by user? Or,
    • As you mentioned, copy/paste links in a repeater on the client's page

    There are lots of options. Think of these API's as toolboxes that allow you to create the scenario that suits your client's requirements.

    • Like 2
  6. Solved! Thanks @Zeka

    Solution:

    <?php 
    
    // in my auto-loaded custom module 
    
        public function init() {
            $this->addHookAfter('ProcessPageView::pageNotFound', $this, "unpublishedProfile");
        }
    
    
        public function unpublishedProfile (HookEvent $event) {
            $page = $event->arguments(0);
            if ($page->isUnpublished() && $page->template == 'profile')
                $this->wire('session')->redirect($this->wire('pages')->get(1312)->url);
        }

     

    • Like 2
  7. For pages with a particular template, I would like them to display/redirect to a different page from the normal http404 page when status is unpublished. Can't figure out what to hook and where. Un-working code is:

    <?php
    
    // in my auto-loaded custom module
    
        public function init() {
          // this hook doesn't catch... returns the normal http404 page for unpublished template=profile pages
            $this->addHookBefore('Page("template=profile")::loaded', $this, "unpublishedProfile");
        }
    
        public function unpublishedProfile (HookEvent $event) {
            $page = $event->arguments(0);
            if ($page->isUnpublished())
                $this->wire('session')->redirect($this->wire('pages')->get(1312)->url);
        }

    Also tried to hook After page loaded with same result, ie default Page Not Found shown.

    Help & suggestions to fix much appreciated.

    Cheers
    psy

  8. @rick

    Rather than use the problematic PW front-end image uploads, I went for uppy and with @Robin S' amazing help, got it working. Tus/Uppy has a nice drag-n-drop user interface, overcomes file size limits, allows for resumable uploads + more.

    In Robin's example, he saves the images to a new page. In my case, I prepended the page id and an underscore to the filename in the Uppy js code. Then, in the uppy server page code, identify the required page by exploding the filename on the underscore.

    Maybe time to get a new horse?

     

    • Like 2
  9. Thanks again @teppo. I tried a few things with my limited knowledge of Apache including changing root dir privileges to 777 (scary I know!) for testing purposes to see if the error message was correct. Didn't change anything so switched the root dir privileges back to PW preferred settings.

    Obviously something is amiss and fairly certain it's not that SeoMaestro cannot create the file. I even saved a dummy sitemap.xml file (updated module prefs to same file name) in the root dir and still no luck. I've used this module before with success on other sites with earlier PW versions.

    Problem reared its head with PW1.0.142+. Wondering if maybe latest .htaccess or other is affecting things? @Wanze?

  10. On 11/1/2019 at 7:33 AM, titanium said:

    Somebody mentioned that earlier in this thread, but no solution was proposed (the error went away automagically in that case). 

    Problem didn't go away for me. It still exists and no solution found. Turned off sitemap.xml generation to lose the error message. Still hoping for a fix

  11. Nice ? home page nav was a bit confusing for me, eg when clicking on 'About', it scrolled to your About section but the menu disappeared. There was no obvious way to get back to the top of the page. When I scrolled up, the menu had disappeared. Using iMAC with wide screen. Going into phone mode in Chrome dev tools made it a bit easier... Otherwise, well done you!

    • Like 1
  12. I want to have both a login form and a registration form on the same page. After much tweaking in CSS & Hooks, I managed to get @ryan's LoginRegister module to display as required. All goes well until it doesn't, ie if there is an error in the form submission.

    Each form has the wrapper ID hardcoded to "LoginRegister". Problem is when both forms are on the same page, both forms get the error messages and the Login form turns into a Register form. See attached before-and-after images and my code is in the 'spoiler'.

    Spoiler
    
    <?php namespace ProcessWire;
    
    // the message doesnt work but the goose user who tried to login with both client and admin roles is auto-logged out
    $message = '';
    if ($input->get('logout')==1 && $input->get('g')==1 ) {
        $message = "You have been auto-logged out as the account you logged in with has both Client and Admin privileges which would completely screw up the application!";
    }
    
    if($user->isLoggedin() && !$input->get('profile') && !$input->get('logout')) {
        // you take over and render your own output or redirect elsewhere
        $session->redirect('/dashboard/');
    } else {
    
        $wire->addHookBefore('Inputfield::render', function ($event) {
            $inputfield = $event->object;
    
            if ($inputfield instanceof InputfieldTextarea) {
                // textarea input
                $inputfield->addClass('form-control');
                $inputfield->columnWidth = 100;
    
            } else if ($inputfield instanceof InputfieldText) {
                // includes most single-line text types
                $inputfield->addClass('form-control');
                $inputfield->columnWidth = 100;
    
            } else if ($inputfield instanceof InputfieldSubmit) {
                // submit button
                $inputfield->addClass('button button-rounded');
            }
    
            if ($inputfield->required) {
                $inputfield->addClass('required');
                $inputfield->attr('required','required');
            }
        });
    
        $loginRegister = $modules->get('LoginRegister');
    
        $loginRegister->set('renderStyles', false);
        $loginRegister->set('renderScripts', true);
    
        if ($input->get('register')|| $input->get('register_confirm')) {
            $loginRegister->set('features', array('login', 'register', 'profile', 'forgot','login-email'));
        } else {
            $loginRegister->set('features', array('login', 'profile', 'forgot','login-email'));
        }
        $loginForm = $loginRegister->execute();
    
        $loginRegister->set('features', array('login', 'register', 'profile', 'forgot','login-email'));
        $input->get->register = 1;
        $registerForm = $loginRegister->execute();
        $input->get->register = 0;
    }
    ?>
    
    <region id="regHeadCSS">
        <link type="text/css" href="/wire/templates-admin/styles/font-awesome/css/font-awesome.min.css?v=30e" rel="stylesheet">
    
        <?php
        foreach(wire('config')->styles as $file) : ?>
            <link rel='stylesheet' type='text/css' href='<?=$file?>' />
        <?php endforeach;?>
    
    </region>
    
    <region id="regContent">
        <!-- Content
        ============================================= -->
    
        <section id="content">
    
            <div class="content-wrap">
    
                <div class="container clearfix">
    
                    <div class="col_one_third nobottommargin">
    
                        <div class="well well-lg nobottommargin">
                            <?=$message?>
                            <?php if (!$input->get('register') && !$input->get('register_confirm')) : ?>
                            <?php
                                try {
                                    echo $loginForm;
                                } catch (WireException $e) {
                                    echo "Too many failed login attempts.<br>" . $e->getMessage();
                                }
                            ?>
                            <?php endif;?>
                        </div>
    
                    </div>
    
                    <div class="col_two_third col_last nobottommargin">
                        <?=$page->body?>
                        <?php
                        // needed to avoid server 500 error when user tries to login too many times in the other form
                        try {
                            echo $registerForm;
                        } catch (WireException $e) {
                            echo "Too many failed login attempts.<br>" . $e->getMessage();
                        }
                        ?>
                    </div>
    
                </div>
    
            </div>
    
        </section><!-- #content end -->
    
    </region><!--regContent-->
    
    

    Help to fix much appreciated

     

    Screenshot 2019-11-02 13.51.49.png

    Screenshot 2019-11-02 13.52.19.png

  13. 1. I'm getting the following error on a number of sites running PW3.0.142+

    Failed to generate the XML sitemap

    Even though the API should have write access to the site root (unless something has changed in .htaccess?). I know others have raised this issue but I cannot figure it out.

    2. The module default values do not parse PW vars while per page SeoMaestro fields do, eg in the field default Meta section:

    1233989935_Screenshot2019-10-2920_25_21.png.c522e052b63f4a5ea46db99ab667da65.png

    literally displays {title} in the browser tab. However if on a page seo override I uncheck the Inherit default value checkbox and enter:

    1858803940_Screenshot2019-10-2920_29_18.png.590bed6c44c221714da658cd36f13de6.png

    on page output, it correctly parses headline (1st priority) or page title (2nd priority) text in the browser tab.

    Help to fix both issues much appreciated.

     

×
×
  • Create New...