-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
What does the devtools network tab say?
-
Hi Ryan, thank you! That's a very welcome addition! ? I'll buy it soon. One quick question: How does it handle situations when some people share the same PW user to log in and edit pages?
-
Setting the icon markup of the wrapper does not work, because this also affects all following inputfields and always sets the same icon on all inputfields. This is what I came up with now: // add method to set icon of inputfield manually $this->addHook("Inputfield::setIcon", function($event) { $field = $event->object; $name = $field->name; $icon = $event->arguments(0); $field->parent->addHookAfter('render', function($event) use($name, $icon) { $search = " for='Inputfield_$name'>"; $event->return = str_replace( $search, $search."<i class='$icon'></i> ", $event->return ); }); }); Usage is even simpler: $field->setIcon('fad fa-link');
- 1 reply
-
- 1
-
-
I'm glad you believe @Robin S if you didn't want to believe me ? Just create a custom $page method that does your logic, then you have your own performant API. That should get you started: $wire->addHook("Page::readByUser", function($event) { $result = $this->database->query("SELECT id,templates_id FROM pages LIMIT 5"); $ids = $result->fetchAll(\PDO::FETCH_OBJ); $user = $event->arguments(0); d("check for user $user"); $event->return = $ids; }); d($page->readByUser($user));
-
Thx for the example. Yeah, I need auto height - seems to be possible only via javascript ? Not for me ? This answer states this solution: .fa-rotate-45 { -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); } So if I wanted to rotate an icon 45 degrees when hovered I'd have to create a class like .hover-45:hover { transform: rotate(45deg); } Do I still need those -webkit -moz -o ... versions? Is using javascript for that any bad? Sorry, we are getting off-topic. So maybe someone can ask my questions and then we'll come back to the web manifesto ?
-
Did you see my example gifs? Maybe you (or anybody else) can show me how I can SLIDE-toggle the white div here: https://jsfiddle.net/baumrock/1uaLmxo7/7/ BTW: It's also easy to rotate elements with the uikit js framework ? util.Transition.start(burger, { 'transform': 'rotate(270deg)', }, duration, 'ease');
-
What exactly is easier? I'd be happy to get an example.
-
No, I thought so as well, but this is really just toggling the visibility. You can then add some animations, but that's not the same as the jQuery slideToggle does: This is UIkit toggle + animation slide-top (see how the yellow div toggles instantly): This is a custom transition changing height from 0 to auto smoothly:
-
I'm not so sure about that. PW often treats pages as... well... pages. Not plain ids. So it could happen that you load all those pages into memory which would be a huge overhead and could drastically slow down your site. You can even build your own method that gets all users that visited a page: if($page->wasViewedBy($user)) { echo "You have read this post"; } else { echo "Wow! We have new content for you ;)"; } Add a timestamp to your DB table and you can even collect statistics about page visits... Not complicated at all. Try to do that with PW page reference fields ? If you want something future-proof: Overcome your fears and build a custom DB table ?
-
EDIT: Just realized that this will set the icon of every field! I'll look into that... Add this to /site/ready.php if($page->template == 'admin') { $config->styles->add("/site/assets/fontawesome/css/all.css"); } Then you can use all FontAwesome icons in your backend. To set the icon of an Inputfield you need a little hack, because the InputfieldWrapper adds the FA4 prefix automatically. The fix is quite easy: $wrapper = $field->parent; $wrapper->setMarkup([ 'item_icon' => "<i class='fad fa-image'></i> ", ]); $field->icon = 1; // set icon to anything not null Voila, you can use Duotone icons for your fields: PS: There's also a module by @Macrura but that didn't work for my usecase. And adding 3 lines in site/ready.php to use an existing folder of FontAwesome is better than installing another module and copying files over... PS: My approach does of yourse NOT show icons in the GUI of fields and templates. It's a code- or file-based approach that works in hooks and process modules.
- 1 reply
-
- 2
-
-
I'd build a custom DB table that holds the id of the page and the id of the user that visited that page. page | user -----|----- 1 | 41 2 | 41 3 | 41 Get all pages that have been visited by the admin? SELECT page FROM visitedpages WHERE user = 41 Get all users that visited page 1? SELECT user FROM visitedpages WHERE page = 1 Executing custom SQL is as easy as that: Thousands of pages? No Problem ? Thousands of users? No Problem ? PS: If you only want an array of all page ids:
-
Personally I stick to uikit only. Especially on free modules everybody who is still using one of the "old" themes is free to file a PR... But I've never had this request. Maybe nobody is using any of my modules ? But just in case someone was using one, I guess it might make more sense to put the effort into switching from the old themes to uikit than supporting old themes in new modules.
-
Hi @Jonathan Lahijani thx for that link. It looks nice indeed. Nonetheless I'm not sure how useful it would be. I'm not doing a lot of frontend, and ~5€/month doesn't sound too bad, but, well... it's 60€ per year and I'm not sure if I want to spend that. I think I don't need that fancy screenshot and zooming stuff (or do I?!), so I just hacked together a simple html page that shows an input for an URL and loads iframes in different sizes: https://bernhardbaumrock.github.io/devtools/ First problem I got was the same-origin restriction, so I copied the HTML file to my PW site. Well... that does not have synchronized scrolling but maybe it could still be helpful? This could also quite easily be turned into a PW module that hooks into the 404 exception when logged in as Superuser on /devtools url (or the like). What do you guys think? Anybody up for that? ? Here's the code: https://github.com/BernhardBaumrock/devtools
-
Hi @ukyo thx for fixing the images. Ok now I also got how one can use their own icons, nice work ? Could you please elaborate a little more on that? I didn't see any problems so far.
-
Just wanted to thank you @Tom. for that brilliant hint! I'm not that experienced in frontend stuff, so basic tasks like slide-toggling a menu can really be a pain for me ? I've always made it easy for myself and just included jQuery for such things... Today I tried the UIkit JS utils and it's not that hard to do (here I'm using Zepto.js, but that's not a necessity): var util = UIkit.util; $(document).on('click', '.tm-burger', function(e) { e.preventDefault(); var $menu = $('#tm-menu-section'); var element = util.$('#tm-menu-section'); var duration = 700; if($menu.height()) { // hide menu $menu.height(element.scrollHeight); util.Transition.start(element, { 'height': 0, 'overflow': 'hidden', }, duration, 'ease'); } else { // show menu $menu.removeAttr('hidden'); $menu.height(0); $menu.css('overflow', 'hidden'); // trigger window resize to make sure that the menu renders correctly $(window).resize(); util.Transition.start(element, { 'height': element.scrollHeight, 'overflow': 'show', }, duration, 'ease').then(function() { $menu.height('auto'); }); } }); The benefit here is that I don't need any dependencies and I can create any transitions that I need and I'm not limited to jQuery's .slideUp() .slideDown() etc. ?
-
Thx @netcarver, but that does not seem to be an IconPicker Inputfield, or am I missing something? ? Anyway, it's always good to have options ?
-
Hi @ukyo I knew there where some Icon Pickers already, but thought it would be fun to build my own ? Also in your module's thread the images are broken, so I didn't get a good first impression... How would I make your module work with a paid version of FontAwesome? Is that possible?
-
RockAwesome ProcessWire Fieldtype to easily choose FontAwesome Icons Usage Install the module. Set paths in the Inputfield's settings page. Add a RockAwesome field to any template (or change an existing TEXT field). Preview https://modules.processwire.com/modules/fieldtype-rock-awesome/ https://github.com/BernhardBaumrock/RockAwesome
- 25 replies
-
- 12
-
-
$config->urls->templates with absolute URL?
bernhard replied to Jonathan Lahijani's topic in API & Templates
Am I the only one often needing a httpsUrl instead of a httpurl? https://github.com/processwire/processwire/pull/116/commits/25be5b54edc16edc80b337723145142660f795c6 Maybe it would make sense to have not only $config->url() and $config->path() but also $config->httpUrl() and $config->httpsUrl() $config->url("/var/www/foo/bar/site/templates/style.css"); // /site/templates/style.css $config->path("/site/templates/style.css"); // /var/www/foo/bar/site/templates/style.css $config->httpUrl("/site/templates/style.css"); // http://www.foo.bar/site/templates/style.css $config->httpsUrl("/site/templates/style.css"); // https://www.foo.bar/site/templates/style.css $config->httpsUrl($pages->get(2)); // https://www.foo.bar/processwire/ What do you think? You can support my request here: https://github.com/processwire/processwire-requests/issues/326 -
How to install processwire on Laragon?
bernhard replied to franciccio-ITALIANO's topic in Getting Started
Just use the root user with no password (of course only for development). See -
Thx, seems that I missed that ?
-
Just a FYI @teppo I'll definitely need a site search on my next project so I'll try your module soon. I've found https://markjs.io/ today and it seems to be great (and MIT). Maybe this could be implemented into your module for highlighting the results? Or did you have any other solutions in mind? Would you be interested in me bringing markjs into your module or would you prefer if I build something seperate?
-
Bug report - Get $user->language in hook Pages::saveReady
bernhard replied to DV-JF's topic in Multi-Language Support
It's not a bug as Ryan just explained in the issue: -
Finally got around to playing with UIKIT: it's great but ...
bernhard replied to OrganizedFellow's topic in Dev Talk
Could you please mark the topic as solved? Thx ? -
Snippet for adding a module config class: "Module Config Class": { "prefix": "moduleConfig", "body": [ "class ${YourModule}Config extends ModuleConfig {", " public function getDefaults() {", " return [", " 'fullname' => '',", " ];", " }", " public function getInputfields() {", " \\$inputfields = parent::getInputfields();", " ", " \\$f = \\$this->modules->get('InputfieldText');", " \\$f->attr('name', 'fullname');", " \\$f->label = 'Full Name';", " \\$f->required = true;", " \\$inputfields->add(\\$f);", " ", " return \\$inputfields;", " }", "}", "", ], "description": "Module Config Class" },
- 246 replies
-
- 4
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with: