Leaderboard
Popular Content
Showing content with the highest reputation on 06/22/2015 in all areas
-
Hi @tourshi, welcome to PW. If you want do "things" with / from a page in a function, you best pass the $page as parameter or get its handle with the wire() function: function getTitle($page) { $t = $page->title; function getTitle() { $page = wire("page"); $t = $page->title; But if you only want one of two field values, depending if it is populated or not, as I can see from your code, you don't need a function for that. You can use it directly in your template with an OR selector as follows: $t = $page->get("long_title|title"); This will give you the value of long_title if there is one, OR, if it is empty, it gives you the value of title. Coming back to the function: fastest way is to pass the variable into the function, because the variable is an object what is passed by reference. There is no drawback or overhead, its the fastest way. If you, for what ever reason, cannot pass a API variable to a function, you always can get there handles via the wire("nameofapivar") function. This works everywhere, but has a (very little) overhead. Also I don't think it is measurable with a few calls, (less than 100).5 points
-
I like the "increase memory limit" part the best Btw here's an Advanced WordPress Development Checklist: DONT4 points
-
2 points
-
I cant wrap my head around it, why a blog tool with a checklist of 100 tasks became so popular as CMS.2 points
-
I am pleased to announce the full release of version 2.6.1 of the language pack. (Versioning now moving to match that of PW itself) I setup a new module info section in the modules repo. http://modules.processwire.com/modules/french-language-pack/ (might not be live as you read this) Also, the GitHub repo is moving to https://github.com/plauclair/pw-lang-fr/. Head over to the releases page for download https://github.com/plauclair/pw-lang-fr/releases. Enjoy!2 points
-
And here's some code for those that may need it: $myfieldset_start = false; foreach ($page->template->fields as $field) { // or something like $this->templates->get('templatename')->fields if ($field->name == 'myfield') { // opening element of a fieldset is just the field name you gave it $myfieldset_start = true; } elseif ($field->name == 'myfield_END') { // ending element is field name with _END on it - break out of the loop if we reach this break; } elseif ($myfieldset_start == 'true') { // otherwise we are iterating fields in the chosen fieldset so do what you like here echo $field . "<br>"; } }2 points
-
It would be awesome users could size their images for the RTE (rich text editor) using preset cropping sizes. This could really help ensure consistency across a site for editors that need to add images and reduce the amount of training needed when dealing with images. third part image crop fields do this really well, but do not offer a way to use the crops in the RTE. Image: Look next to the cancel button, there is a pulldown for image size presets. Drop down menus allows users the ability to select some preset image cropping dimensions. Crop guides would keep the aspect ratio, and return the desired image size. Pick custom size and the cropping guides would work as they normally do (free form) Other approaches: ProcessPageImageSelect could be made hookable in a way that images from third party image modules can add images to the RTE image selection page. i've been trying to get a preset image crop sizes into the RTE editor for a while now. I tried to use the hooks in ProcessPageImageSelect in-combination with the CroppableImage module but there is no hooks for this as (as far as I know). $this->addHookAfter('ProcessPageEditImageSelect::execute', $this, 'HookPageImageSelect'); The hook above will allow me to add images to the image selection modal, but I still can't get images that image to be addable to the Rich Text Editor on click. I was able to get the desired functionality by modifying core module ProcessPageImageSelect. Maybe if ProcessPageEditImageSelect->getImages() was hookable images from other modules could be added without modifying core modules.1 point
-
I've just found the Killer Wordpress Checklist... http://capsicummediaworks.com/killer-wordpress-checklist/ Beside it is funny to read points like these (with some comments compared to PW): development and launching checklist have some very general hints so the are in fact important but some special WP ones i'm getting some bad feelings... Change DB Table names (kidding?) Delete Sample Config File (what?) Remove Default Content (this i've done with the installation?) Make a Plugin List - few recommended Plugins <about 20 items list> (Hmm lets see i think i need my favorite 5 Helper modules to get started and watching for special needs) Implement Security (Is this weird my whole cms should be secure i need not to "implement" this..hmm) And at the end the two funniest points are for sure security and maintaince...some hand picked prevent directory access (PW default) use iThemes Security (Ahh right i've to implement security somehow...no need in PW) The most points are very general on Webdesign or building a blog...but some funny things are listed and it such "lists" are maybe a Marketing Tool if some designer have spare time we could setup a sleeker checklist for a "best practice" PW website? regards mr-fan1 point
-
If the user can select multiple files for download, you know where they are. You simply can link to the page(s) of them if you have set the new property of mimetype for that template. Then PW will send the apropriate headers for that mime type. But I would bundle all selected files into one ZIP and present that link for downloading.1 point
-
We should have some sort of best comment of the week...you are nominated....1 point
-
Hi Friedrich, welcome to the forum! This can be done in several ways. and depends a lot on some factors. Will there be any news in several languages, or they will always be each one in it's own language? If they will be sometimes in only one language, but other times in more, I would ignore those active checkboxes in the settings, and create my own checkboxes in the main edit page. For this, simply create a page field type, choose checkboxes as the input field type and choose the languages page as parent. Add it to your articles template, and you will have the three languages, with a checkbox each. Then, on your template you can do something like this to get the news: //let's say the new field is called "active" $lang = $user->language; //the language being viewed in the browser $news = $pages->find("parent=news, active={$lang}"); we're getting all the news where this language is selected foreach($news as $article) { // echo things } If each article will be only in one language you can simply create a news page for each languages and create the articles for that language as children with non multi language fields. Then show one news parent or the other depending on the language. This solution is probably simpler for the editor, but probably a little more difficult to set up.1 point
-
In fact my example was very much simplified for this post. As we're using TemplateTwigReplace, we benefit from Twigs "extend" and "block" syntax. Regarding the Project named above there is one _base-template.twig that handles the "normal" output. It looks like this: <!DOCTYPE html> <html lang="de-DE" class="no-js"> <head> {% include 'includes/htmlhead.twig' %} {% block htmlHead %}{% endblock htmlHead %} </head> <body data-module="ajaxcontent,fallback" class="js-template-{{ page.get('template')}}" itemscope itemtype="http://schema.org/WebPage"> <div id="pt-main" class="pt-perspective"> <div class="pt-page pt-page-current js-pt-main"> {{ page.renderChunk('chunks/header.twig', config.ajax ) }} {% block header %}{% endblock header %} <!-- #### MAIN CONTENT START #### --> <main role="main"> {% block mainContent %}{% endblock mainContent %} </main> <!-- #### MAIN CONTENT END #### --> {{ page.renderChunk( 'chunks/footer.twig', config.ajax ) }} </div> <!-- ADDITIONAL CONTENT WILL BE PLACED HERE. --> <div class="pt-page ajaxcontent js-ajaxcontent" id="ajaxcontent"> <div class="ajaxcontent__inner"> <div class="ajaxcontent__content js-ajaxcontent-content"></div> </div> </div> <!-- 2nd LEVEL ADDITIONAL CONTENT WILL BE PLACED HERE. --> <div class="pt-additional-content ajaxcontent js-ajaxcontent-lvl2" id="ajaxcontent-lvl2"> <div class="ajaxcontent__inner"> <div class="ajaxcontent__content js-ajaxcontent-lvl2-content"></div> </div> </div> </div> {% include 'includes/javascript.twig' %} {% block beforeBodyEnd %}{% endblock beforeBodyEnd %} </body> </html> basically it contains the html wrapper plus some blocks that can or cannot be filled with further content. The _ajax-template.twig acts as a wrapper for pages that are displayed via ajax: {% block header %}{{ page.renderChunk('chunks/header-ajax.twig') }}{% endblock header %} {% block mainContent %}{% endblock mainContent %} {# block footer %}{{ page.renderChunk( 'chunks/footer.twig', config.ajax ) }}{% endblock footer #} As you can see it is missing all chrome and unneeded stuff plus it includes a special header (one without navigation elements other than a "close" button and the logo). ALL pages extend those two default wrapper-templates and add their content to the respective blocks. A (very simple) template for outputting pages like legal information with just a headline and content field would then look like this: {% set extendsVar = config.ajax ? '_ajax-template.twig' : '_base-template.twig' %} {% extends extendsVar %} {% block mainContent %} <div class="row"> <div class="small-12 columns editor"> <h1 class="headline headline--stage">{{ page.get('headline|title') }}</h1> {{ page.content }} </div> </div> {% endblock %} ... based on the config.ajax value the template chooses which layout file will be extended and then renders it's output to the mainContent area. simple as that1 point
-
Ryan replied back to my issue on the Form Builder support forum. Here is the solution he suggests. And the way I did it myself, before I saw his post: Both work, but it's my guess that Ryan's is the better way, as he has way more experience then I have.1 point
-
An update to the xsl sylesheet above. Tablesorter is not required for zebra striping, and so jquery is not required. Added CSS3 nth-child(odd) styling instead. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XML Sitemap</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body { font-family: Helvetica, Arial, sans-serif; font-size: 18px; color: #545353; } table { border: none; border-collapse: collapse; } #sitemap tr.odd { background-color: #eee; } #sitemap tbody tr:hover { background-color: #ccc; } #sitemap tbody tr:hover td, #sitemap tbody tr:hover td a { color: #000; } #content { margin: 0 auto; width: 1000px; } .expl { margin: 10px 3px; line-height: 1.3em; } .expl a { color: #da3114; font-weight: bold; } a { color: #000; text-decoration: none; } a:visited { color: #777; } a:hover { text-decoration: underline; } td { font-size:14px; } th { text-align:left; padding-right:30px; font-size:12px; } thead th { border-bottom: 1px solid #000; cursor: pointer; } tbody tr:nth-child(odd) { background-color: #E8E8E8; } </style> </head> <body> <div id="content"> <h1>XML Sitemap</h1> <p class="expl"> Generated by <a href="http://processwire.com/">Processwire</a> this is an XML Sitemap, meant for consumption by search engines. </p> <p class="expl"> You can find more information about XML sitemaps on <a href="http://sitemaps.org">sitemaps.org</a>. </p> <p class="expl"> This sitemap contains <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs. </p> <table id="sitemap" cellpadding="3"> <thead> <tr> <th width="75%">URL</th> <th width="12%">Last Change</th> </tr> </thead> <tbody> <xsl:for-each select="sitemap:urlset/sitemap:url"> <tr> <td> <xsl:variable name="itemURL"> <xsl:value-of select="sitemap:loc"/> </xsl:variable> <a href="{$itemURL}"> <xsl:value-of select="sitemap:loc"/> </a> </td> <td> <span> <xsl:value-of select="sitemap:lastmod"/> </span> </td> </tr> </xsl:for-each> </tbody> </table> </div> </body> </html> </xsl:template> </xsl:stylesheet>1 point
-
1 point
-
Hey @marcus Regarding the module downloads, I am not sure if you noticed my earlier posts http://harikt.com/blog/2013/11/16/composer-support-for-processwire-modules/ http://harikt.com/blog/2013/11/19/composer-support-for-processwire-part-2/ That way we can install modules on the site/modules folder as we are doing with just composer. I am also missing how processwire will support composer in the future, if anyone can give some insights / links it may also help. EDIT : I am happy to change the vendor name and give to processwire if Ryan likes it. Thank you1 point
-
We've made a lot of progress on our generator. We're now using Gulp to automate everything, but still, it ties in strongly with our PW Boilerplate. You'll likely find a lot of useful things in our generator that you can take over. Some useful things: automatically downloads the latest PW automatically gets a few PW Modules we use in all projectsMarkupSimpleNavigation ProcessRedirects MarkupSitemapXML install npm and all the dependencies in the Gulpfile initialises bower The generated Gulpfile has a bunch of useful utilities: browsersync sass and coffee compilation asset revisioning for production cache busting (like fingerprinting in Rails apps) rsync utilities Instead of bash scripts being run, we've opted for a small Node app for better cross OS support. Feel free to fork it, and add and remove as you see fit.1 point
-
1 point
-
Just wanted to note here in this post that I've built a configurable module for this and also included optional support for automatically generating the password for the new user. You can read more about it here: https://processwire.com/talk/topic/7051-email-new-user/ Also, there was some discussion above about how to get the entered password in plain text, but I don't think anyone actually came up with a working solution. I found that you can hook on InputfieldPassword::processInput and then you can get the plain text password with $event->object->value1 point
-
what.i use this is good it does.work top {not buttock}, of htaccess u will.put it . enjoy <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType image/x-icon "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/octet-stream "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" </IfModule> <IfModule mod_headers.c> <FilesMatch "\\.(ico|jpe?g|png|gif|swf|woff)$"> Header set Cache-Control "max-age=31536000, public" </FilesMatch> <FilesMatch "\\.(css)$"> Header set Cache-Control "max-age=2692000, public" </FilesMatch> <FilesMatch "\\.(js)$"> Header set Cache-Control "max-age=2692000, private" </FilesMatch> <FilesMatch "\.(js|css|xml|gz)$"> Header append Vary: Accept-Encoding </FilesMatch> Header unset ETag Header append Cache-Control "public" </IfModule> <IfModule mod_deflate.c> AddOutputFilter DEFLATE js css AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule>1 point