-
Posts
1,334 -
Joined
-
Last visited
-
Days Won
62
Everything posted by BitPoet
-
My primary application will be for our intranet site where we have complex product datasheets and configuration information that link to parts sheets, supplier information, technical standards and whatnot. Keeping linked documents up-to-date is quite important, and with today's innovation speed we've got about twenty to thirty doc updates per workday. I'll probably keep creation rights for the MediaLibrary template limit to admins though, to avoid over-eager users cluttering every page with a media child (just in case...).
-
MediaLibrary Update: MediaLibrary can now be found in the official module list. Out of necessity, I've started to implement a simple media library module. The basic mechanism is that it adds a MediaLibrary template with file and image fields. Pages of this type can be added anywhere in the page tree. The link and image pickers in CKEditor are extended to allow quick selection of library pages from dropdowns. In the link picker this happens in the MediaLibrary tab, where you can also see a preview of the selected image. In the image picker, simply select a library from the dropdown at the top, everything else is handled by standard functionality. I've put the code onto github. This module is compatible with ProcessWire 3. Steps to usage: Download the module's zip from github (switch to the pw3 branche beforehand if you want to test on PW 3.x) and unpack it into site/modules Click "Modules" -> "Refresh" in the admin Click "Install" for MediaLibrary For testing, create a page with the MediaLibrary template under home (give it an expressive title like 'Global Media') and add some images and files Edit a differnt page with a CKEditor field and add a link and an image to see the MediaLibrary features in action (see the screencap for details) Optionally, go into the module settings for MediaLibrary Note: this module is far from being as elaborate as Kongondo's Media Manager (and doesn't plan to be). If you need a feature-rich solution for integrated media management, give it a look. Feel free to change the settings for MediaFiles and MediaImages fields, just keep the type as multiple. There are some not-so-pretty hacks for creating and inserting the correct markup, which could probably be changed to use standard input fields, though I'm a bit at a loss right now how to get it to work. I've also still got to take a look at error handling before I can call it fit for production. All feedback and pointers are appreciated (that's also why I post this in the development section). Edit 09.03.2016 / version 0.0.4: there's now also a "Media" admin page with a shortcut to quickly add a new library. Edit 01.05.2016: Version 0.0.8: - The module now supports nested media libraries (all descendants of eligible media libraries are also selectable in link/image picker). - There's a MediaLibrary::getPageMediaLibraries method you can hook after to modify the array of available libraries. - You can switch between (default) select dropdowns or radio boxes in the module configuration of MediaLIbrary to choose libraries. Edit 10.10.2018: Version 0.1.3: - Dropped compatibility for ProcessWire legacy versions by adding namespaces - Allow deletion of libraries from the Media overview admin page - Added an option to hide media libraries from the page tree (optionally also for superusers)
- 68 replies
-
- 23
-
-
Update: thanks to LostKobrakai's prompting, I've looked at delayed operation and implemented a mix of immediate and delayed updates. This is a major change, so the code is still in alpha and available in the dev branch at github (there are also some screenshots to be found in the readme). I've incorporated an admin page where pending updates can be seen and triggered, but the whole thing is still lacking permissions checks (both for visibility of the admin page and for listing viewable/editable pages), which may require some big changes to the code (perhaps even split hooks and update functionality into separate modules). Of course, if that happens, I'll make sure updating works. Every page clone now stores a todo entry in the database. When cloning a page, URL updates are triggered after the last page has been cloned and at most 50 pages are updated (configurable in module settings). The rest of the updates have to be triggered manually in the admin page (for now). So if anybody wants to give it a try, I'd love to get some feedback.
-
Your page needs a parent.
-
I haven't tested it with extensively large subtrees, only ones of about 30 pages. I'm still a bit of two minds whether limiting replacements to href and src attributes is in fact necessary. If not, a direct database approach may be worth thinking about. Otherwise, the multiple statements necessary to catch all variants of attributes and quotes probably outweigh the memory and CPU impact of the regex replacement. I guess a lot depends on the environment too - cloning huge trees may run into memory or time limits in itself. Now that I've written this, delaying the rewrites may be an option as well - just collecting ids in Pages::cloned if recursion level is > 0, then processing the rewrites after the last call to Pages::cloned.
-
This combination shouldn't give any troubles. Have you checked that InputfieldSelectMultiple.module is where it is supposed to be (under wire/modules/Inputfield), just to rule out ftp transfer errors?
-
Actually, commenting out the php flags makes sense on reasonably current PHP versions (>= 5.4). Directory options may not be overrideable due to apache's config. @ngrmm: what ProcessWire and PHP versions are you running?
-
Here's a short module that adapts href and src links in CKEditor fields when a page is cloned: ProcessPageCloneAdaptUrls Normally, href links and image urls still point to the original page's assets folder when you copy (clone) a page. This module hooks into Pages::cloned and adapts all src and href attributes found in HTML tags that point to the old assets directory, rewriting them to link to the copy's assets. This module was motivated by a feature request (#1687) on PW's github tracker. Requires: ProcessPageClone (Core, but not installed by default) Status: beta Download: git repo Module directory Feedback: welcome!
-
Set Markup inside a InputfieldRadio Option Label
BitPoet replied to Orkun's topic in General Support
The longer answer: yes, a hook should work, but you'll have to modify the html output of InputfieldRadios::render. Quick&Dirty: /* site/ready.php */ wire()->addHookAfter('InputfieldRadios::render', null, 'addOptionImages'); function addOptionImages($event) { $obj = $event->object; if($obj->name == "NameOfYourRadiosField") { $opts = $obj->getOptions(); $ret = $event->return; foreach($opts as $key => $value) { $id = $obj->id . "_" . wire('sanitizer')->name($key); $ret = preg_replace( "~(<input.*?id='{$id}'.*?)<span.*?>.*?</span>~", '$1' . "<img style='display: inline;' src='$value'>", $ret ); } $event->return = $ret; } } The "display: inline" style is needed to keep the image on the same line as the radio button. -
@Lenz: the fields works like a charm on 3.0.9. The message you get is because to work, ImageMarker needs a regular image field as well on the template. You add the image field to the template and enter the name of that image field in the imagemarker field's settings. Then, on a page with that template, you add an image to the imagefield, save the page and imagemarker picks up the image from that field.
-
Problems using the new field rendering option in PW3
BitPoet replied to Juergen's topic in General Support
Try leaving out the leading slash, i.e. echo $page->render('singleimage', 'products/singleimage'); -
@adrianmak, Edge is known to be a bit picky with loopback connections. While 127.0.0.1 has been fixed when Spartan was renamed to Edge, other IP addresses bound to the loopback driver still can make problems. One of these two changes usually works: Open a DOS box (best use "run as administrator") and type "CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe" Or: go to Control Panel -> Internet Options -> Security -> Local Intranet -> Sites and uncheck the option "include all local (intranet) sites not listed in other zones"
-
1. Relatively easy, yes, as in no harder than dealing with them if you build a full solution from scratch. 2. No, there isn't. A fieldtype for that would need to be tailored to a certain implementation logic. 3. There's nothing specific in the api, no, but if you build a field type for it, you can use all the field selectors together with a few lines of PHP to set headers, etag etc. based on the field value to output an image and hook into the existing logic of pagefile/pageimage to add your db inserts on top of PW's builtin upload logic. 4. You can either use PW's database interface (class Database, which is just a small wrapper around mysqli), use plain PDO or include your own database access class. PW has a few reasons for adding images to pages, one of the being security - if you have $config->pagefileSecure enabled and define access restrictions to a page/template, you implicitly limit access to its files too. Any option to store files completely outside PW's page structure will break that relationship and require you to limit access rights on a per-image basis (or to implement your own permissions logic that checks access rights with the pages the images are used in, meaning you still need to "assign" images to pages somehow). I do understand the wish to provide some kind of "image pool" though - it's, in fact, one of the next things I have to tackle for our company's intranet, as we have a lot of repeating images and documents in the technical manuals section there that need to be kept in sync. I'll probably introduce some kind of "files library" template, add library pages in places in the tree wherever security settings change and extend the pwlink and pwimage plugins for CKEditor to allow easy picking and inline uploading. You'd need to do something similar to be able to pick your external images. As for outputting files/images not stored in the usual location under the page's directory in assets/files, the code for FieldtypeSecureFile (which stores page files outside of the web root) is worth looking at.
-
This should IMHO be filed as a bug. The problem here is that Pagefiles::cleanBasename doesn't account for this kind of URLs without a trailing filename. It simply splits the string at the last dot in the URL when it should only look for dots after the last path separator (and perhaps also account for a reasonable maximum extension length, but that's another thing). This is the relevant code: $dot = strrpos($basename, '.'); $ext = $dot ? substr($basename, $dot) : ''; It should (untested) be sufficient to change it to: $slash = strrpos($basename, '/'); $dot = strrpos($basename, '.', $slash); $ext = $dot ? substr($basename, $dot) : ''; if(strlen($ext) > 10) $ext = substr($ext, 0, 10); // Not sure what a reasonable default would be here
- 10 replies
-
- 1
-
-
- api
- page creation
-
(and 2 more)
Tagged with:
-
"equipment" is a page array. You can use the removeAll method to clear it of all items: $player->of(false); $player->equipment->removeAll(); $player->save(); $player->of(true);
-
Strange behavior: Pagetable field and German Umlauts
BitPoet replied to Juergen's topic in General Support
Support for %e is a bit of a fuzzy subject (which is mentioned in the docs). I'd create a small php file and call it directly to check for %e support: <?php header('Content-type: text/plain'); echo 'Month is ' . strftime('%e') . PHP_EOL; ?> EDIT: Didn't look closely enough. As dates in February and April are shown, it's unlikely that it's about %e. Pleaes move on, there's nothing to see here. -
I can think of two possibilites to approach this: Reverse your logic and add the products in a page field to the option page (not really intuitive) Add a counter field to the option pages' template(s) and update the value through a hook on Pages::save for your product template (with a similar looping logic as in your code above). Then you can easily filter with $optionpages->children("usecount>0").
-
You can't use a wildcard in Access-Control-Allow-Origin if you want to do XHR. A simple workaround would be to return the value of the Origin request header instead of the wildcard.
-
You need to allow credentials for cross domain requests for ajax calls in the mobile framework you use. For regular xhr objects this just means setting xhr.withCredentials = true; but depending on the library, this may have to be done in a less direct way (like in beforeSend in jquery where you have access to the xhr object).
-
At least in 2.7.0 it already removed pipe characters (this is from Sanitizer::selectorValue): $value = str_replace(array('*', '~', '`', '$', '^', '|', '<', '>', '=', '[', ']', '{', '}'), ' ', $value);
-
Uhm. Shouldn't it be $selection = implode("|", $input->get->filter); ?
-
PW running on other Domain/Server than the Domain, using .htaccess
BitPoet replied to Frangoo's topic in General Support
Is mod_proxy active on server a? Edit: with server a I mean the customer's original server. -
Sorry, didn't look closely enough. I meant h2 span:hover { text-decoration: underline; } Though for that kind of styling you should always use classes or ids to avoid styling unrelated content. I'm assuming here that you want the text to underline when you hover over it. If you want to style the text on hovering over the image, it's a completely different topic.
-
Fieldtype vs. Inputfield - What's the difference?
BitPoet replied to steveooo's topic in Module/Plugin Development
A good place to start reading would also be the Map Marker field module, which Ryan created as an example. In short: The Fieldtype is responsible for taking care of saving to and loading from the database as well as sanitizing values, creating the database table(s) and assembling the correct database query from a selector. The Inputfield renders the input form elements and processes form input. InputfieldMapMarker generates its input elements manually in the render method, but you can also use InputfieldXXX modules (like it does in ___getConfigInputfields) and add those to an InputfieldWrapper, then render that. -
That is what the :hover pseudo class is for. span.caption:hover { text-decoration: underline; }