Jump to content

ukyo

Members
  • Posts

    262
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by ukyo

  1. Use an images field on your template and if you have a field with ckeditor there is an image icon click it and you will see uploaded images to your page. Select image and make your align left, right or center. Save the page :)

    After you did these steps add class to your css file about alignments you can find sample css codes here : https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/templates-admin/styles/main.css#L432

    Also if you add description on your uploaded image, alt tag will be appear with your description.

    • Like 1
  2. Can you try this :

    /**
     * Uikit Navbar Navigation
     *
     * @param $items
     * @param array $templates
     * @param string $tag
     * @param int $maxDepth
     * @return string
     */
    function renderNavigation($items, $templates=[], $tag="", $maxDepth=0) {
    
        $templates = (!empty($templates)) ? $templates : [];
        $currentPage = wire('page');
        $output = ($tag!="") ? "\n<div class='uk-dropdown uk-dropdown-navbar'><$tag class='uk-nav uk-nav-navbar'>" : "";
        foreach($items as $item)
        {
            $class = [];
            $dropdown = "";
            $hasChild = FALSE;
            $url = $item->url;
            $caret = "";
            $filter = "";
    
            if(! empty($templates) && !in_array($item->template, $templates) && $maxDepth)
            {
                $filter = "template!=";
                $x=1;
                foreach($templates as $template)
                {
                    $i=$x++;
                    $separator = ($i!=count($templates)) ? "|" : "";
                    $filter .= $template.$separator;
                }
                if($item->numChildren($filter) > 0)
                {
                    $hasChild = TRUE;
                    $class[] = 'uk-parent';
                    $url = '#';
                    $dropdown = "  data-uk-dropdown";
                    $caret = " <span class='uk-icon-angle-down'></span>";
                }
            }
            // Set Active Class !
            if($currentPage->id == $item->id || $currentPage->parents("id=$item->id,template!=home")->count() > 0) $class[] = 'uk-active';
    
            $class = (!empty($class)) ? " class='" . implode(' ', $class) . "'" : "";
    
            $output .= "\n<li{$class}{$dropdown}><a href='{$url}' title='{$item->title}'>{$item->title}{$caret}</a>";
    
            if($hasChild) $output .= renderNavigation($item->children($filter), $templates, "ul", $maxDepth-1);
    
            $output .= "\n</li>";
    
        }
        $output .= ($tag!="") ? "\n</$tag></div>" : "";
        return $output;
    }
    
    // Usage :
    $homepage = $pages->get(1);
    $navigation = renderNavigation($homepage->and($homepage->children), array("don't", "display", "these templates", "children"), "", 1);
    
    echo "\n<nav class='uk-navbar'>
          \n\t<ul class='uk-navbar-nav uk-hidden-small'>
          \n\t\t{$navigation}
          \n\t</ul>
          \n</nav>";
    
    • Like 2
  3. AvbImage - Image Manipulator Module for ProcessWire

    This module using Intervention Image PHP image handling and manipulation library.

    Update Status

    • Module and InterventionImage Library update - 10-12-2015
    • More performance imporements - 18-11-2015
    • Module Update and Performance Improvements - 17-11-2015
    • First Commit - 28-10-2015
    Requirements
    • ProcessWire >= 2.5.11
    • PHP >=5.4
    • Fileinfo Extension
    Supported Image Libraries
    • GD Library (>=2.0)
    • Imagick PHP extension (>=6.5.7)
    For usage and methods please look githup repo : README.md >

     

    For issues and fix and corrections please use Githup Repo

    • Like 14
  4. On my side, i tested some methods for add resized or watermarked images to variations for admin panel :
     
    If i change your suffix and if i use variation name like ProcessWire (width x height) :
     

    // From
    $suffix = "-pim2-{$suffix}";
    
    // To
    $suffix = ".pim2.{$suffix}";
    
    // And making watermarking by use variation like ProcessWire
    // Watermark from original
    $dImage = $image->pim2Load("{$image->width}x{$image->height}")->watermarkLogo($wmPath, 'c', '2')->pimSave();
    
    // Create medium size from original with watermark
    $mImg = $image->pim2Load("1130x500")->resize(1130, 500)->watermarkLogo($wmPath, 'c', '2')->pimSave();
    
    // Use medium size for resize (will be watermarked making only resize)
    $mImg = $mImg->size(750, 300);
    
    

    Created files on disk :

    rh4c5k.jpg

    Here created variations :

    r88me0.jpg

    Original Size Watermarked

    2uiu6bc.jpg

    Medium Size Watermarked

    ndvimt.jpg

    I am not displaying original image. Displaying watermarked and sized images. Like this if i delete images from admin panel delete image and variations, clean work. Now the problem is file sizes as you see on my screen shot.

    2h6dnxx.jpg

    Order : Original Image - Watermarked from Original image - Resized from watermarked original image 

    Edited: File sizes screenshot added.

    • Like 1
  5. Thank you for this Great Module !

    I stuck with variations. Without resize image by using ProcessWire api variations not working. If i use ProcessWire sizing api with pim2Load function there are many files (no need them).

    What i want to do :

    1- Make a duplicate from original and keep original

    2- Apply watermark to duplicated image

    3- If result is fine for resize size, use this image for resizing (OR) resize from original and apply watermark, but don't make duplicates (for better watermark result)

    4- See variations on admin panel, if i delete all images or specified image, delete all variations. (Deletion not working with below codes, if i delete image on filesystem i can see all watermarked images)

    // Also i tried with pim2Load('wmi')->stepResize(image->width)->watermarkLogo($wmPath, 'c', '2')->pimSave();
    $duplicateAndWatermarkOriginal = $image->pim2Load('wmi')->watermarkLogo($wmPath, 'c', '2')->pimSave();
    // Create a small sized 1130x500px
    // Also i tried with pim2Load('wmi')->stepResize(1130, 500)->watermarkLogo($wmPath, 'c', '2')->pimSave();
    $smallFromDuplicated = $duplicateAndWatermarkOriginal->size(1130, 500);
    

    Watermarked images is working and not regenerating them. Also i added a log message to your class. For check whats happened.

                if('page'==$this->entryItem) {
                    $this->message("pageImage setFilename, setOriginal, targetFilename :: {$targetFilename}", Notice::log);
                    $pageimage = clone $this->pageimage;
                    $pageimage->setFilename($targetFilename);
                    $pageimage->setOriginal($this->pageimage);
                    return $pageimage;
                }
    

    And i can have logs messages. Sometimes i can see variations count going up (from 2 variations to 4 variations) on list view of images but when i click variations its going down (from 4 variations to 2 variation) and on the list created images not appear.

    Now i am running script like this and variations are working :

    // Duplicated from original (same size), and apply watermark (here we have 2 original size without watermark and 1 with watermark)
    $dImage = $image->size($image->width)->pim2Load('wmi')->watermarkLogo($wmPath, 'c', '2')->pimSave();
    // Create small size from $dImage already watermarked (not have a duplicate  )
    $sSizeImage = $dImage->size(1130, 500);
    // If i want to create from original again (we have one more duplicate)
    $sSizeFromOriginal = $image->size(1130, 500)->pim2Load('wmismall')->watermarkLogo($wmPath, 'c', '2')->pimSave();
    
  6. After several years use Twitter Bootstrap changed my front-end framework.

    What i tried :

    - Materializecss

    - Google Web Starter Kit

    - Foundation

    - Yahoo Purecss

    - Some other frameworks and some of other twitter bootstrap things

    I found Uikit, it's has simple and effective solutions. Many time you don't need extra js libraries and design is clean (this is important for me).

    • Like 1
  7. Nice work @Mike Rockett !

    I am using my own FormBuilder generally, a config file based form builder :) Six months ago i created a git repo uploaded files but can't finalize it.

    If you interest and want to check it maybe you can use some useful things : https://github.com/trk/AvbFormBuilder

    It has a validation library and google re-captcha support.

    Some of features :

    - Form generation

    - Mail send

    - Validation

    - Re-captcha support

    - Template support for custom input elements

    - etc.. :)

    Its working on my side but need to make it better.

    • Like 2
  8. Thanks heaps! Now there are no errors.

    Now I'm just left wondering, why recaptcha validation is not ok :)

    I was testing on localhost and it should work with the API keys, but I'll try in the online website next.

    Edit: didn't work in the online website either..

    You can test recacptcha also on localhost ! But be sure you are using virtual host or when you create a key be sure there is your local domain also added.

  9. Can you try it like :

    wire('modules')->get('FrontendUser')->form->fhSubmitBtn->error('reCAPTCHA validation not ok!');
    

    And also you can use loaded modules or variables like this :
     

    $form->addHookAfter('processInput', function() use($fu, $recaptcha, $input) {
            $recaptchaverify = $recaptcha->verifyResponse($input->post('g-recaptcha-response'));
            if(!$recaptchaverify) {
                 $fu->form->fhSubmitBtn->error('reCAPTCHA validation not ok!');
            }
    });
    
    • Like 1
  10. You loaded recacptcha module :

    $recaptcha = $modules->get('Recaptcha');
    

    No need to reload module :

    $recaptchaverify = wire('modules')->get('Recaptcha')->verifyResponse(wire('input')->post('g-recaptcha-response'));
    

    You can use it like : 

    $recaptchaverify = $recaptcha->verifyResponse(wire('input')->post('g-recaptcha-response'));
    

    and same for frontenduser module

    is there a funtion $fu->fhSubmitBtn->error() ? I didn't use and check module codes or usages be sure there is a function exist... Error mean there is no function exist !

  11. what is the advantage over using the built-in cache or procache?

    ProCache is a paid version cache module ! Do not compare this free module with paid modules but if you know how to extend module you can do it like ProCache or better than it !

    Build-in cache module is only support database cache, on the templates side its support files cache but you can't use it for custom uses. I used both of them there is no place for expire time set option, cached data info or clear cache section etc..

    If you check  phpfastcache offical website you will see advantages of using this module. For example you can use multiple cache drivers in same time with different options or you can set a default options for use any where. You can set expire date, you can clear cached data (for files, sqllite drivers), and you can set the what need to do after a page modified etc.....

    Here is my website : http://altivebir.com/ using this cache module.

    post-2064-0-66734800-1437383025_thumb.pn

    • Like 1
  12. With ProcessWire 2.6.7 or newer version, You can do something like :
     
    ready.php, simple example, you can extent this may i missed something and you can have better idea for best caching methods..

    // You can set your site templates for cache or ignore cache
    $allowedCacheTemplate = array(
            'home',
            'basic-page',
            'contact' => array(
                'ignore' => true
            ),
            'reference',
            'reference-list' => array(
                'list' => true,
                'childTemplate' => 'reference',
                'pagination' => true
            ),
            'service-list' => array(
                'pagination' => true
            )
        );
    
        wire()->addHook("Page::render", function(HookEvent $event) use($page, $user, $input, $allowedCacheTemplate) {
            $template = $event->template;
    
            // Check allowed cache templates, if template has ignore or don't have template return $event->return;
            if(isset($allowedCacheTemplate[$template]['ignore']) || !isset($allowedCacheTemplate[$template])) return $event->return;
    
            // Start Caching
            $avbfastcache = wire('modules')->get('AvbFastCache');
            $_c = phpFastCache($avbfastcache->storage, $avbfastcache->getConfig(), $avbfastcache->expire);
            // Set default keyword
            $keyword = $template . $page->id . $page->modified . $user->language->id;
            // For list view, get children last modified unix time and add it to $keyword
            if(isset($allowedCacheTemplate[$template]['list'])) {
                $filterTemplte = (isset($allowedCacheTemplate[$template]['childTemplate'])) ? $allowedCacheTemplate[$template]['childTemplate'] : NULL;
                $getLastModified = $avbfastcache->getLastModified($page->id, $filterTemplte);
                $keyword .= $getLastModified;
            }
            // If there is a pagination on this template also add $input->pageNum to template
            if(isset($allowedCacheTemplate[$template]['pagination'])) {
                $keyword .= $input->pageNum;
            }
            // Out keyword is ready to use, check cache exist?
            $html = $_c->get($keyword);
            // If cache not exist create cache
            if($html == null) {
                $html = $event->return;;
                $_c->set($keyword, $html);
            }
            // return the result
            return $html;
        });
    

    With this method you can cache template before render !

    • Like 1
  13. AvbFastCache Module

    Module AuthorBig Thanks to phpFastCache authorsUsage Almost Like original phpfastcache library :

    I made some modification on original phpfastcache library for use it with ProcessWire. On my side i tested files and sqlite its look working well.

    You can set default settings from module setting panel or you can use it like original library with custom settings for each call, from module setting panel you can set storage type, cache path, security key, fallback and also you can delete cached data from module settings panel.

    Modified set function, working like core $cache->get function this function will check a cached data exist ? if not save cache data and return cached data back.

    Here is some example usages :

    // Load Module
    $AvbFastCache = $modules->AvbFastCache;
    // Set cache settings from module
    $_c = phpFastCache($AvbFastCache->storage, $AvbFastCache->getConfig(), $AvbFastCache->expire);
    
    $output = $_c->set("cacheKeyword", function($page)) {
        $output = '<h1>{$page->title}</h1>';
        $output .= "<div class='body'>{$page->body}</div>";
        
        return $output;
    });
    
    //=> OR
    
    // Do MemCache
    $_c2 = phpFastCache("memcached");
    
    // Write to Cache Save API Calls and Return Cache Data
    echo $_c2->set("identity_keyword", function()) {
        $results = cURL->get("http://www.youtube.com/api/json/url/keyword/page");
    
        $output = "";
        foreach($results as $video) {
            $output .= $vieo->title; // Output Your Contents HERE
        }
    
        return $output;
    }, 3600*24);
    
    // This will check id=1 or parent_id=1 and will return last modified page UNIX_TIMESTAMP as result
    echo $AvbFastCache->getLastModified(1);
    
    // This will check id=1 or parent_id=1 and template=basic-page and will return last modified page UNIX_TIMESTAMP as result
    echo $AvbFastCache->getLastModified(1, 'basic-page');
    
    // What can you do with last modified dates ? Let me show you an example
    
    // Think you are in news page, $page->id is news page id we are using $user->language->id because if we have multi language website
    // Here getLastModified() function will get last modified date for us, if news page or children pages have any update new cache data will be created automatically
    // Like this you can set expire time 0 unlimited from module panel !
    // Think we are in "new-list" template and listing children pages
    $keyword = "newsPage" . $page->id . $user->language->id . $AvbFastCache->getLastModified($page->id, 'news-single');
    
    // Load library with your settings
    $_c3 = phpFastCache($AvbFastCache->storage, $AvbFastCache->getConfig(), $AvbFastCache->expire);
    
    // Write to Cache and Display Result
    echo $_c3->set($keyword, function($page)) {
    
        $output = "";
    
        foreach($page->children as $p) $output .= "<h2>{$p->title}</h2>";
    
        return $output;
    });
    
    
    You can check phpfastcache usage from phpfastcache wiki or phpfastcache offical website

    Note : I didn't tested this module with older ProcessWire versions, tested with 2.6.1 or newer versions. Module not have core dependency, it could work also older versions but need to check for be sure !

    • Like 7
  14. Now i am trying to use core comment module and i want to change render result. Need to rewrite same codes like original codes, normally just need to change item's css classes and some visual html items.....

    My question is ?

    Why php, html, css and js codes inside same php file? When i check a core php file or a module file its look like spaghetti and hard to understand what happening there. 

    Separate main php codes from html, css, js will be helpful to understand and override view file easily. We won't need to rewrite same codes again and again.

    For example :

    - wire/modules/Fieldtype/FieldtypeComments/views/renderComments.php

    Here we can have a views folder for render results, view file for each render operation

    and we can override this view file by creating a folder inside our templates folder

    - site/templates/overrides/modules/Fieldtype/FieldtypeComments/views/renderComments.php

    as you can see like this way we can only modify view results, no need repeat ourself always..

    also with this method, it will be easy to modify InputField displays...

    With this method we can easily adapt our front-end frameworks (like : twitter bootstrap, foundation, uikit and others)

    Current status : if you want make changes repeat core codes and change just html elements, css styling or javascript codes..

  15. Nice module! Love the good work ( Ellerine saglik ukyo ;-) )

    I would like to know if it's possible to include the icon package of foundation http://zurb.com/playground/foundation-icon-fonts-3

    regards,

    Gerald

    Yes its possible, you can configure module as your needs

    On Install i get :

    Parse error: syntax error, unexpected '[' in /somepath/site/modules/FieldtypeFontIconPicker/InputfieldFontIconPicker.module on line 22

    I guess this is because that server uses php 5.4.   that does not support the new [] Syntax.

    The funnie thing about that is that it should support it !

    - Corredted with last commit, you can download 0.0.6 version

    • Like 1
  16. Its not good solution for me, because i have some slide items on homepage and some other stuff, when my customer add some data do this slider whole cache will be cleared also.

    Homepage is not symbolic page for me, I am using homepage for website settings also other main things also.

    Whenever I need to force a cache reset, let's say after modifying some code that won't automatically be shown, I'll just save the front page to force a full website refresh.

    I have cache_expire field on homepage also, in dev mode making value "0" for production changing it.

  17. Little Test Results :
     
    Single page load times :

    LOCAL TEST
    - Before : 28rjpf7.jpg

    - After : 9fz8fl.jpg

    SERVER TEST

    - Before : 2191m5c.jpg

    - After: m8itzo.jpg
    Homepage load times (Homepage getting slider and some of other data from different page->children and homepage have 2 repeater and website settings data etc..):

    LOCAL TEST

    - Before : 35dc1fk.jpg

    - After : 2j0m9on.jpg

    SERVER TEST (With custom .htaccess rules and google page speed module)

    - Before : wa3klc.jpg 

    - After : 2r4s7sh.jpg

    If @ryan put a clear cache button on admin panel, it will be good than delete caches manually from database :), also i think website cache and module and other system cache need to be separated.

    Also, Cache Class could have an option about use file cache or db cache. Current cache function here :

    public function get($name, $expire = null, $func = null)
    

    If we can send an bool value like : $fileCache=true Cache class could use file caching. If false or nothing Cache class could continue to use db cache.

    public function get($name, $expire = null, $func = null, $fileCache=false)
    
  18. Hi, 

    I wrote a little function for get last modified date from pages. What is this function making ? You can get last modified page modified date from given id, parent or from all pages. What can you do with last modified date? You can use it for caching pages. Here is little function and some example usages.

    /**
     * Get last modified page modified date from given $id, $parent_id, $templates_id or from all
     *
     * @param bool $id
     * @param bool $parent_id
     * @param bool $templates_id
     * @return mixed|string
     */
    function getLastModified($id=false, $parent_id=false, $templates_id=false) {
        if(!is_null($id)) {
            $where = "";
            if(is_bool($id) != true) {
                $where = " WHERE";
                $where .= ($parent_id) ? " parent_id = {$id}" : " id={$id}";
                $where .= ($templates_id) ? " AND templates_id = {$templates_id}" : "";
            }
            $results = wire('db')->query("SELECT MAX(modified) as modified FROM pages{$where}");
            if($results->num_rows > 0) {
                $result = $results->fetch_assoc();
                $search = array(' ', '-', ':');
                $replace = array('', '', '');
                return str_replace($search, $replace, $result['modified']);
            }
        }
        return "";
    }
    
    Gist : https://gist.github.com/trk/a9d7e01ecfa6e40b65bc

    Example Usages :

    <?php
    echo $cache->get("top-navigation" . getLastModified(true), function($pages) {
         echo renderYourNavigation();
    });
    ?>
    
    Here we are checking all pages and getting last modified date from database. With this way you don't need a cache time. If you update any page from your site, your cache file will be updated also.
    <?php
    echo $cache->get($page->name . getLastModified($page->id), function($page) {
        echo $page->title;
        // Do what you want...
    });
    ?>
    
    With this usage : you can use $page->name + last modified date as cache name and you page will be cached and to be updated always..
    <?php
    echo $cache->get('news-' . getLastModified(1234, true), function($pages) {
        $pages->get(1234);
        // Print out your news...
    });
    ?>
    
    If you set second parameter as "true" function will check pages if have parent_id = 1234.
    • Like 2
×
×
  • Create New...