-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
Simplest way to add or edit a TinyMCE keyboard shortcut
Soma replied to alan's topic in General Support
Soma to the rescue. Actually I'm not a TinyMCE expert, but working with PW pushed me to get into it, since there were a couple bugs in PW implementation for IE. Having clients that work with IE8-9 made me take care of it even if I didn't wanted. Ok here it comes: I quickly searched and looked at how shortcuts are implemented in TinyMCE, and since 3.+ there's a addShortcut command. http://www.tinymce.c...tor.addShortcut These are the shortcuts currently in TinyMCE: ctrl+z Undo ctrl+y Redo ctrl+b Bold ctrl+i Italic ctrl+u Underline ctrl+1-6 h1-h6 ctrl+7 p ctrl+8 div ctrl+9 address (ctrl on Mac = cmd) I quickly created plugin you can use to define your own. It's different for Mac than Windows, and also Browser dependent I think. Install this plugin as you would for the bramus_cssextras. Same procedure. Here's the plugin code and attached for dowload. For finding commands you can search the tiny_mce_src.js. This plugin will add a shortcut ctrl+e to format a block as a blockquote. // Create a new plugin class (function(){ tinymce.create('tinymce.plugins.SomaShortcuts', { init : function(ed, url) { ed.addShortcut('ctrl+e','Format Blockquote', ['FormatBlock', false, 'blockquote'], this); } }); // Register plugin with a short name tinymce.PluginManager.add('soma_shortcuts', tinymce.plugins.SomaShortcuts); })(); Cheers. soma_shortcuts.zip -
I didn't mean to step on your module and philosophy. Just wanted to give an example. However, you're right, so I created a fork and commited my changes for you to see easier. https://github.com/somatonic/TemplateBadges
-
Just committed another update. I made sure the default value (if any defined) is also being returned by the API even if the page is not yet saved and there's no range value in the Database.
-
Thanks joe_g for mention it. I just updated the module and fixed the issue with the default value.
-
Some random thoughts. 1. Maybe have the module configurable and be able to define a default icon or space for all in case none is set, to visually align the pages if only some have an icon set. Just thought it could make sense. 2. It would be handy to see the selected icon visually. Either the icons itself beside the select or highlighted on the icon table.
-
Not sure you have seen it: http://wiki.processw...Module_Creation Not sure if it covers everything yet, but we are still in the beginning of the advanced documentation (wish it were there when I began), so if you can find time and wanted to help it would be greatly appreciated. Most things I learned by studying code and try out things, there's not really much about module once you get into it. People tend to make a BIG thing about it, when it isn't. After a couple modules you'll be much more comfortable. Ahh PHP 5.3? I don't know if it's a good idea if the CMS is for php 5.2.4+. Also since jquery core is not something I want to change, I slightly changed the .js you serve with the module to make it work. I recoded your module to work, also with < 5.3 and replaced the hooks with alternative. I recognized while playing with it, why you came to use the internal hooks to add script and css. The order of how scripts get added you can only control very little and depends when the module gets executed and what type of module it is, but I also got problems with js getting added when used in the module init(). I think it has to do with the autoload and not being a inputfield or process module. http://processwire.c...r-jquery-core/. Maybe time for Ryan to take a look at it again. Adding script through a method in your module that will get executed when your hook method is being called is the way to go for this kind of module. For the icon panel, you can use InputfieldMarkup to render markup. Also if you want to have the extra panel to be together with the select inputfield, you could create a InputfieldFieldset and put both inside. But in this case appending InputfieldMarkup to the form is ok. I also moved the js init call into the .js file where it belongs to. See attached the modified module code. I really like this so far. Installed my 1'000 famfam icon set hehe. http://www.famfamfam.com/lab/icons/silk/ TemplateBadge.module.zip
-
Yeah, I can see why you chose to make it that way. From the code base, it all looks good, nothing wrong there. I'm not too sure about those hooks you have in your hook method's. Especially "$icon->addHookAfter('render', null, function(HookEvent $event) use($icons, $icons_url, $icons_license) {..." And "$t->addHookAfter('render', $this, 'hookAfterRender');" which I don't think is really needed. Now when I try to install I can't and get error in admin once I check for new modules. Parse error: syntax error, unexpected T_FUNCTION in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/site/modules/TemplateBadges/TemplateBadge.module on line 93
-
Thanks for sharing! Looks cool so far. Great learning for sure. What have you used that it requires a newer version of jQuery core? Might be only me, but I'd have gone for a icon font, but having .png icons makes it easier to implement of course. When I've seen that color picker, I immediately thought about my ColorPicker Fieldtype that would be nice to have here maybe. I'm not too happy with the badge label. Look much like a button, and personally it add's too much color and noise for my taste. I also wanted to mention that this "Badge label" can also be already done by using custom label setting in templates. Just add as a field string "title template.label". And it will show the label of the template. Only took a quick glimpse at the module, and couldn't understand how it's all done, also it looks very different from how I would've implemented it. But keep up the good work and congratulation on your first module!
-
How to hide the admin (backend) login from bots and most people
Soma replied to alan's topic in General Support
Who said you have to include the admin link in your footer? *confused* -
500K is quite a lot. So even 250k is a lot and surprized it works. It's not about time it takes to upload and the size of the csv. It will generate 250k pages in memory and it looks a lot like a memory or time execution limit. Recently we had to up the memory limit up be able to upload 6MB+ images on a server so it's not alwas directly related. I think importing such amount of data in chunks is your best bet. It was discussed in the CSV thread an other occasion here in the forums.
-
Adde pull request for modified ProcessTemplate translation file. Also translated a new file "ThrottleLogin" module, json file attached. wire--modules--sessionloginthrottle-module.json.zip
-
echo nl2br($image->description);
-
One thing I noticed is that it can take quite some time to load the statistics and I think there should be some ajax loader indicator animation while it's loading.
-
I can reproduce this and it's also clear that 0 (zero) is like false|null . So I think PW checks for if there's a page with that name and it fails. Not sure about it, but why do you have to name it 0?
-
Hmm, it does work for the default. You might have to tell a little more about your languages. You might have to compare it against "en"?
-
Forgot you were asking where to put it, sorry. But glad you found it out. Now to make the current active try this: //what is the current language $lang = $user->language; //this line sets the language to sites default. //"default" is the name of the sites primary language, in this case it's English $user->language = $languages->get("default"); $activeClass = $lang->name == 'default' ? ' class="on"' : ''; echo "<li><a$activeClass href='/en{$page->url}'>EN</a></li>"; //this sets the language to German, so you can get the pages URL in German $user->language = $languages->get("de"); $activeClass = $lang->name == 'de' ? ' class="on"' : ''; echo "<li><a$activeClass href='/de{$page->url}'>DE</a></li>"; //this sets the language back to current one again $user->language = $lang;
-
You're all right there mrs! The module is to create speaking language urls, which is best practice regarding SEO. BTW Are you female? Not that it matters.
-
This I like more: http://www.photoswipe.com/ Ok not really lightbox, but nice gallery for different devices.
-
It's just that the add form method isn't yet hook-able. It's not about not being permitted and it comes down to each process that creates form for various tasks in the admin. I think Ryan will be glad to make it hookable. I also was starting a module to add icons to templates but stopped working on it. Just made css tests to see what can be done. Since my teflon theme already has icons in the page tree I tried to find a convenient solution. I was thinking about either extending the template edit form or just keep it on the module setting screen to be able to set a icon for each template on one screen. Either way it would work but still some things to figure out. I made the buildEditForm hookable and was able to add tab easily. Edit: this is example module to add tab and a checkbox to template edit screen. Once the buildEditForm() is hookable. Just add ___ to the method. <?php /** * ProcessWire Page List Icons * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class PageListIcons extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Page List Icons', 'version' => 100, 'summary' => 'Add an icon per template in the admin page list', 'href' => '', 'singular' => true, 'autoload' => true ); } public function init() { //$this->config->scripts->add($this->config->urls->PageListIcons . "PageListIcons.js"); //$this->config->styles->add($this->config->urls->PageListIcons . "fontello/css/fontello.css"); $this->addHookAfter("ProcessTemplate::buildEditForm",$this,'addForm'); $this->addHookBefore("ProcessTemplate::executeSave",$this,'saveForm'); } public function addForm($event) { $form = $event->return; $template = $this->templates->get($event->arguments('template')); $t = new InputfieldWrapper(); $t->attr('title', $this->_x('Icons', 'tab')); $t->head = $this->_('Add icons to pages'); $t->attr('class', 'WireTab'); $t->add($this->buildEditFormIcons($template)); $form->add($t); } public function buildEditFormIcons($template) { $field = $this->modules->get('InputfieldCheckbox'); $field->label = $this->_('Test'); $field->attr('id+name', "mycheckbox"); $field->attr('value', "test"); if($template->mycheckbox) $field->attr("checked","checked"); return $field; } public function saveForm($event) { $value = isset($this->input->post->mycheckbox) ? $this->input->post->mycheckbox : null; $templ = $this->templates->get($this->input->post->id); if($templ->mycheckbox != $value) $this->message($this->_("Template saved: Test")); $templ->mycheckbox = $this->input->post->mycheckbox; } }
-
You can add tabs via the field "FieldsetTabOpen" to templates. If you are talking about the template edit screen you're right.
-
Share your experiments. I thought I'd share something I've done a little while ago experimenting and trying out things you can do with js and SVG. So vector graphics for the web even older browsers can (IE had VML). 1. One is the famous Chromachron watch, I've created an accurate browser version (with a little twist in the center, which is not on the real clock). Done using the amazing javascript SVG library RaphaëlJS. http://soma.urlich.ch/chromachron/ 2. A fun experiment with RaphaëlJS for drawing and toxiclibjs (from java), a great physics library for the physics. You can click to fix the tail of the spring. (better have a fast browser) http://soma.urlich.ch/toxictale/ Have fun.
-
Let me search that for you: There's some dozen more around about this subject, but I'm too lazy search. Multiple categories will also result in multiple urls, so setting canonical meta url might be a good idea. Depends what you want, but I don't see any issues with it if you handle it in some way.
-
Well i thought i explained it already. In a bootstrap theres no page context thus no output formatting. Sent from mobile.
-
The only thing I see now to reproduce your fatal error ist writin ->first instead of ->first() This has come up so often it was clear from the beginning it has to do with it being and "Pageimages" WireArray instead of a single object of type "Pageimage". That's most likely when you directly request it and include the PW index.php. BTW do you also bootstrap that when doing normal function call when included? Because it's not necessary on a PW template file. SO you most likely have to also include a check for using first() or not depending if it's an ajax request or not.
-
I see, still even if I rebuild yours and also include the bootstrap, I can call it directly via a ajax jquery script. And I can reproduce that what we first answered. Even if it's a single image field you have to call it with $p->image->first()->sie Now looking again at the error code "Pageimages::size" That's exactly why me and Ryan suggested to try the ->first() method. And my tests show exactly this behaviour. Works fine here so can't really help and don't see anything wrong that sticks out. I have a /site/ajax/ajax.inc.php include_once( $_SERVER['DOCUMENT_ROOT'] . "/index.php"); function generateCart( $pages, $config ) { $p = $pages->get("/about/"); $img = $p->image->first()->size(100,120); return $img->url; } if(wire('config')->ajax){ echo generateCart( wire("pages"), wire("config") ); } And when I call it directly from a pw page <script> $.ajax({ url: "/site/ajax/ajax.inc.php", success: function(data){ $('#bodycopy').html(data); } }); </script> I get this back /site/assets/files/1001/pastedgraphic-1.100x120.png And the image field "image" is limited to 1 max. So in a normal call in a PW page you only would do $page->image->size(100,0)->url