Jump to content

tpr

Members
  • Posts

    2,321
  • Joined

  • Last visited

  • Days Won

    44

Everything posted by tpr

  1. 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.
  2. 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; };
  3. 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
  4. 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)
  5. 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.
  6. Filter pages right on getting them: 1077)->children('template!=exclude')... Edit: shouldn't try being fast when on mobile
  7. Unfortunately it depends on jQuery which I try to avoid if I can, otherwise cool.
  8. 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.
  9. Try setting Mode to DEVELOPMENT or check Superuser force dev mode.
  10. To sum up: this is the standard (github) way of contributing to other's repo.
  11. is "$page->category" a single page? Just make sure it returns the ID when you compare.
  12. If it hides well there's no example to show
  13. 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.
  14. Thanks szabesz, I think I should have more understanding of bernhard's usecase. Fortunately PW is flexible enough to handle such scenarios.
  15. 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.
  16. Yes, animation are too much, otherwise there are many interesting design/UI solutions. Thanks for the insight!
  17. Try $this->configData['already_commented'] Just do a var_dump($this) for example and check what's available. Even better using Tracy Debugger.
  18. 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>';
  19. That should not be undefined. Are you sure _init.php is prepended?
  20. You could do a foreach on the object and create the variables.
  21. //_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.
  22. Do those fields get submitted if you deactivate cache entirely?
  23. 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');
  24. 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.
×
×
  • Create New...