-
Posts
2,321 -
Joined
-
Last visited
-
Days Won
44
Everything posted by tpr
-
Intermediate template structure without string concatenation
tpr replied to Pete Jones's topic in API & Templates
I also vote for using a template engine. For me PW would be only half the fun if I would have to go back to PHP templating Recently I started using no or only minimal grid classes in the markup, and control Layout mostly at csa level. This also leads to simpler markup and even to a more reusable code as html is independent from CSS, so you can use them even if you decide to use another CSS framework next time.- 13 replies
-
- template
- intermediate
-
(and 1 more)
Tagged with:
-
Just tried the AutoGrow CKEditor plugin and works fine (PW 3.013, CKEditor with Lightwire theme). You can add options like these to the "Custom Config Options" to the CKEditor PW field settings: autoGrow_onStartup: true autoGrow_bottomSpace: 20 Or to "/site/modules/InputfieldCKEditor/config.js" if you prefer: CKEDITOR.editorConfig = function (config) { config.autoGrow_onStartup = true; config.autoGrow_bottomSpace = 20; };
-
Thanks netcarver. I have an idea to collect such mini-modules into a one admin helper module but as usual I don't know when will I have to do that
-
This is a simple addition to the admin to automatically resize textareas according to their content. It doesn't work with CKE fields tough. All it needs is a hook in ready.php + copying autosize.min.js to the "site" folder (or elsewhere if you feel so). /site/ready.php: // autosize textareas in admin $page->addHookAfter('render', function ($event) { if ($this->page->template != 'admin') return; $autoSizeJsUrl = wire('config')->urls->site . 'autosize.min.js'; $js = <<< HTML <script> var autosizeTextareas = document.querySelectorAll('textarea'); if (autosizeTextareas.length) { $.getScript("$autoSizeJsUrl", function () { autosize(autosizeTextareas); }); } $('.langTabs').on('tabsactivate', function(event, ui) { var textareas = ui.newPanel.get(0).querySelectorAll('textarea'); if(textareas.length && window.autosize && window.autosize.update) { autosize.update(textareas); } }); </script> HTML; $event->return = str_replace('</body>', $js . PHP_EOL . '</body>', $event->return); }); Edit: fixed updating textareas on activating language tabs (heights weren't updated)
- 18 replies
-
- 10
-
MarkupSEO - The all-in-one SEO solution for ProcessWire.
tpr replied to Nico Knoll's topic in Modules/Plugins
It seems that opengraph tags require "property" instead of "name" in tags: http://ogp.me/ Here is a quick fix (around line 330, added dynamic $attributeName): // add "render" $rendered = ''; foreach($pageData as $name => $content) { // set "property" as meta attribute name instead of "name" if it's an opengraph tag $attributeName = strpos($name, 'og:') !== false ? 'property' : 'name'; switch($name) { case 'custom': break; case 'title': if($this->titleFormat == '') break; $rendered .= '<title>'.$this->parseTitle($page, $content).'</title>'.PHP_EOL; break; case 'canonical': $rendered .= '<link rel="canonical" href="'.$content.'" />'.PHP_EOL; break; default: $rendered .= '<meta ' . $attributeName . '="'.$name.'" content="'.$content.'" />'.PHP_EOL; break; } } Also, it's a good practice to add og:image:width and og:image:height, this ensures the image is loaded on first facebook share (otherwise it's empty). Maybe the module could automatically add these too. -
Filter pages right on getting them: 1077)->children('template!=exclude')... Edit: shouldn't try being fast when on mobile
-
Unfortunately it depends on jQuery which I try to avoid if I can, otherwise cool.
-
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
tpr replied to David Karich's topic in Modules/Plugins
That would be a good practice, but maybe even better having a separate CHANGELOG.md file to log changes. You can also check commit messages to see what has changed, provided that the author included one. -
Try setting Mode to DEVELOPMENT or check Superuser force dev mode.
-
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
tpr replied to David Karich's topic in Modules/Plugins
To sum up: this is the standard (github) way of contributing to other's repo. -
is "$page->category" a single page? Just make sure it returns the ID when you compare.
-
If it hides well there's no example to show
- 12 replies
-
- 5
-
- encrypt
- hide files
-
(and 1 more)
Tagged with:
-
The Matrix Repeater is a godsend. I have much more control on the content the client enters even though it takes some time to build one with the proper fields. I combine it with field templates too as partials. Fortunately they are reusable so with a few basic layout blocks pretty nice things can be built.
-
modifying $config property (e.g. siteSettings) from ready.php
tpr replied to Macrura's topic in General Support
Thanks szabesz, I think I should have more understanding of bernhard's usecase. Fortunately PW is flexible enough to handle such scenarios. -
modifying $config property (e.g. siteSettings) from ready.php
tpr replied to Macrura's topic in General Support
As an alternate solution, you can create a Settings page just for the purpose to store global vars. Especially useful if you deal with multiple languages. I usually add a multilang text area and apply multivalue textformatter (see my sig). Set its access to admin only to avoid others modifying it. In most cases addig it to the Home page is enough. -
Yes, animation are too much, otherwise there are many interesting design/UI solutions. Thanks for the insight!
-
Get module settings in module function
tpr replied to kreativmonkey's topic in Module/Plugin Development
Try $this->configData['already_commented'] Just do a var_dump($this) for example and check what's available. Even better using Tracy Debugger. -
modifying $config property (e.g. siteSettings) from ready.php
tpr replied to Macrura's topic in General Support
Go get a coffee This works too: // _init.php (mind the underscore) wire('testArr', array()); $testArr['initValue'] = 'helloworld'; // home.php (no underscores at all) $testArr['myArr'] = array( 'first' => 'veryfirst', 'two' => 'veryfirst' ); // create variables from $testArr array extract($testArr); echo '<pre>'; var_dump($initValue); echo '</pre>'; echo '<pre>'; var_dump($myArr); echo '</pre>'; -
modifying $config property (e.g. siteSettings) from ready.php
tpr replied to Macrura's topic in General Support
That should not be undefined. Are you sure _init.php is prepended? -
modifying $config property (e.g. siteSettings) from ready.php
tpr replied to Macrura's topic in General Support
You could do a foreach on the object and create the variables. -
modifying $config property (e.g. siteSettings) from ready.php
tpr replied to Macrura's topic in General Support
//_init.php $testVar = new \stdClass(); wire('testVar', $testVar); // home.php (or elsewhere) $testVar->myArray = array( 'hello' => 'world' ); echo '<pre>'; var_dump($testVar); echo '</pre>'; This works fine here. Or am I missing something? Using stdClass can be an issue because you can't add methods to it. If you plan to do so, better using a real class. -
Template caching and deactivating post and get variables - How to?
tpr replied to Juergen's topic in General Support
Do those fields get submitted if you deactivate cache entirely? -
Thanks, that solved it. I remember seeing that header in the jQuery request but haven't try adding manually. That's the corresponding part if anyone needs: request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
-
I got an issue with ajax submitting forms & Tracy. The module is always adding itself to the page, though my intention is to have a json_encoded string as the only response. Now I got this: The reason could be that $config->ajax validates to false because I'm using pure JS instead of jQuery. With jQuery there's no Tracy code appearing. So unfortunately using $config->ajax to decide ajax mode wouldn't help here.
-
Reminds me of this: