Jump to content

ukyo

Members
  • Posts

    286
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by ukyo

  1. 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 !
  2. AvbFastCache Module Github repoModule Authorİskender TOTOĞLUBig Thanks to phpFastCache authorsphpfastcacheUsage 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 !
  3. Your module great ! I have a question for own needs.. is it possible to do this with your module ?
  4. 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..
  5. Yes its possible, you can configure module as your needs - Corredted with last commit, you can download 0.0.6 version
  6. 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. I have cache_expire field on homepage also, in dev mode making value "0" for production changing it.
  7. Little Test Results : Single page load times : LOCAL TEST - Before : - After : SERVER TEST - Before : - After: 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 : - After : SERVER TEST (With custom .htaccess rules and google page speed module) - Before : - After : 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)
  8. 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/a9d7e01ecfa6e40b65bcExample 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.
  9. I created Module with last dev version. Let me check for last stable version and i can see what is problem for oldest versions. Edit: Problem solved can you confirm after update to v0.0.5
  10. My solution for simple forms : Validation Module I used GUMP validation library with my custom usage additions. You can check my usage additions : https://github.com/trk/Validation/blob/master/README.md#example-long-format Also i wrote recaptcha module for form security, but didn't publish it yet: https://github.com/trk/Recaptcha Usage: $recaptcha = wire('modules')->get('Recaptcha')->verifyResponse($_POST['g-recaptcha-response']); if(!$recaptcha) { echo 'reCAPTCHA validation not ok!'; } You can add recaptcha as a rule to validation module like: 'g-recaptcha-response' => array( 'label' => 'Security Question', 'rule' => 'required|boolean', 'type' => 'captcha' )
  11. For compatibility, i will change [$foo, $bar] to array($foo, $bar). - Edit : Done. You can update module.
  12. Z-index values looking ok, but how copyright informations coming up? When i check page render result with firebug, footer section looking ok, .container element inside footer section coming up of absolute element. My solution is hack #content element or #footer .container element by little jquery code. Add a z-index value when document ready to #content "z-index: 2;" or #footer .container "z-index: -1;". Problem solve with this method. You can change InputfieldFontIconPicker.module line 94 with this code, I will update repo also : $output .= "\n<script> \n\tjQuery(document).ready(function($) { \n\t\t$('#{$options['id']}').fontIconPicker({ \n\t\t\tsource: {$options['icons']}, \n\t\t\t{$settings} \n\t\t}); \n\t\tif($('#content').length) { \n\t\t\t$('#content').css('z-index', 2); \n\t\t} \n\t}); \n</script>";
  13. Thanks for your feedback! Z-index problem causing from content section ("<div id='content' class='content'>"). Icon selector z-index value is "10000" and not effecting outside of "content" section, if you add z-index value = 2, to "<div id='content' class='content'>" element its looking ok. Need a hack for ("<div id='content' class='content'>") section by jquery or core team can add a z-index value for this section. If core team can do it, i don't need a hack for z-index. If they can't i can add a little hack for this problem. Will wait for core team answer.
  14. Yes, I submit it. Waiting for approve. Also if you can, can you correct the url of my dev profile False -> /alt-ve-bir-bilisim-teknolojileri/ (Loosing small "ı") True -> /alti-ve-bir-bilisim-teknolojileri/ (Turkish characters ). ı -> i note: I added logo also again. When you make post on dev form profile, if validation is not ok fields coming as blank field.
  15. If you want to access to admin page what will happen? I offer you use an module like Page Protector. Also you can create your custom view file, when you active protector for which page you choose.
  16. V.0.0.2 MarkupIconPicker Markup added.
  17. Thanks for your feedback ! I think, duplicate problem is not actually a problem. Why ? : I took all icons from font-awesome website by categorized and 1 icon may in more than 1 category. I see @Ryan module, i am trying to use always dev version of processwire and i can follow updates, new things better, but you can't use it on page as a field. @Ryan solution is good for templates and field icons select. If you think from customer side : Simple example, think you have links page for social network website. You need an icon for each link page and you can easily select icon from select list. you don't need to search icon class inside font-awesome website or inside a icon class guide. Just select it from list. Also its possible to limit icons from input setting tab by category.
  18. FieldtypeFontIconPicker Supported Icon Libraries FontAwesome 4.7.0 Uikit 3.0.34 IonicIcons 2.0.1 Cahangelog NOTE: Module store data without prefix, you need to add "prefix" when you want to show your icon on front-end, because some of front-end frameworks using font-awesome with different "prefix". Module will search site/modules/**/configs/IconPicker.*.php and site/templates/IconPicker.*.php paths for FieldtypeFontIconPicker config files. All config files need to return a PHP ARRAY like examples. Example config file : create your own icon set. File location is site/configs/IconPicker.example.php <?php namespace ProcessWire; /** * IconPicker : Custom Icons */ return [ "name" => "my-custom-icons", "title" => "My Custom Icon Set", "version" => "1.0.0", "styles" => array( wire("config")->urls->templates . "dist/css/my-custom-icons.css" ), "scripts" => array( wire("config")->urls->templates . "dist/js/my-custom-icons.js" ), "categorized" => true, "attributes" => array(), "icons" => array( "brand-icons" => array( "title" => "Brand Icons", "icons" => array( "google", "facebook", "twitter", "instagram" ) ), "flag-icons" => array( "title" => "Flag Icons", "icons" => array( "tr", "gb", "us", "it", "de", "nl", "fr" ) ) ) ]; Example config file : use existing and extend it. File location is site/configs/IconPicker.altivebir.php <?php namespace ProcessWire; /** * IconPicker : Existing & Extend */ $resource = include wire("config")->paths->siteModules . "FieldtypeFontIconPicker/configs/IconPicker.uikit.php"; $url = wire("config")->urls->templates . "dist"; $resource["scripts"] = array_merge($resource["scripts"], ["{$url}/js/Altivebir.Icon.min.js"]); $resource["icons"]["flag-icons"] = [ "title" => "Flag Icons", "icons" => array("tr", "en", "fr", "us", "it", "de") ]; $resource["icons"]["brand-icons"]["icons"] = array_merge($resource["icons"]["brand-icons"]["icons"], array( "altivebir" )); return $resource; After you add your custom config file, you will see your config file on library select box. Library Title (Location Folder Name). If your library categorized and if you have categorized icons set like uikit and fontawesome libraries, you will have category limitation options per icon field or leave it empty for allow all categories (default). Example : output if ($icon = $page->get("iconField")) { echo "<i class='prefix-{$icon}' />"; } MarkupFontIconPicker Usage // MarkupFontIconPicker::render(YourIconField=string, Options=array) echo MarkupFontIconPicker::render($page->YourIconField, [ 'prefix' => 'uk-icon-', // Icon class prefix, if you have different prefix, default is : "fa fa-" 'tag' => 'span', // Icon tag default is : "i" 'class' => 'fa-lg', // If you have extra cutom classes, for example : icons sizes, Array or Sting value 'style' => 'your custom styles if you have' // Array or String Value ]); Theme support Search support Category support
  19. You can use core translator for translate default "English" language. You will see "/modules/Validation/Libraries/gump.class.php" file when you want to make site translation. If you don't use multi language module you can directly edit this file, you will see lang terms, but for module updates its not good idea edit module file directly.
  20. I am using this module with 2.5.10 dev version and i see 1 issue for updating current cart not working, maybe it causing from my mods. I have some modifications for form validations and call custom view files.
  21. Thank you @Pete ! Also here many example usage : https://github.com/Wixel/GUMP/tree/master/examples but don't forget replace GUMP() with Validation
  22. Validation Module for ProcessWire, Validation module using GUMP standalone PHP data validation and filtering class. That makes validating any data easy and painless without the reliance on a framework. Usage almost same with original GUMP validation class. Extended original validation class for make it multi-language and added 2 new function 1 for field labels, 1 for set and get fields. Module Link
  23. Thanks, First post with a huge translation , I hope it will be helpful for PW Users.
  24. ProcessWire 2.4.2 Turkish Core Translations Status (100%) and some of modules translations included. Turkish Translation Github Repo (For Support)
×
×
  • Create New...