-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
I haven't tried and I don't thin it would work just out of the box, but it would be easy to adapt it to use in front-end. You only need the js script to be added and run the execute like $dt = $modules->get("DatTable"); echo $dt->execute();
-
No it's 2.3 compatible, but every new version has a new checkbox to check and I haven't done it yet. I think there's many modules that suffer from this.
-
You could also add a password field to the admin template.
-
Password field is not made for uae like this. Module config stores json array. But password needs to be a field on a page as it stores pass and salt. Also when using like you do you only use the inputfield and not the fieldtype which encrypts the data. You may consider using a page to store.
-
I often listen to this kind of music while my fingers are dancing on the keyboard..
-
How to set text line/character limits in templates?
Soma replied to photoman355's topic in General Support
Yes helper functions like this can be included using a separate php like in the head.inc and used throughout your templates. I extracted this function from a module I have for a project. This module has various helper function and then I load it in the templates. It's much the same as if I would include a php with functions and just personal preference. For example: $helpers = $modules->get("TemplateHelpers"); then use it like this where I need it. echo $helpers->wordLimiter($page->body); I'm not sure what you mean by applying the function to the body. I use this function to create teaser texts that are limited, and show the complete body only on the detail page. Of course you could modify the body output, that every time you do an echo $page->body, it will run it through a function, but I'm not sure this is a good practice. This using a hook on the formatValue of textfields would do it: (directly in template like a include, or by making it a module) function wordLimiter(HookEvent $event){ $field = $event->argumentsByName('field'); if($field->name != 'body') return; $str = $event->return; $limit = 150; $endstr = ' …'; $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $event->return = $out .= $endstr; } wire()->addHookAfter("FieldtypeTextarea::formatValue", null, "wordLimiter"); // now this will trigger the above hook echo $page->body; But it's a little cumbersome, as you can't set the limit. Also this strips tags and on HTML text you'll lose formatting. But just to show adn example what is possible. From your post I guess you like to do something like: echo $page->body->limit(150); // not possible It's not possible to do this, because the $page->body, body is just a string and not an object you could add methods to it. But something like the following would be possible using hooks. echo $page->wordLimiter("body", 120); You can use addHook to add a method wordLimiter to page: function wordLimiter(HookEvent $event){ $field = $event->arguments[0]; // first argument $limit = $event->arguments[1]; $endstr = isset($event->arguments[2]) ? $event->arguments[2] : ' …'; $page = $event->object; // the page $str = $page->get($field); $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $event->return = $out .= $endstr; } // this will add a custom method to Page object wire()->addHook("Page::wordLimiter", null, "wordLimiter"); // now you can do this echo $page->wordLimiter("body", 100); // or this echo $page->wordLimiter("summary", 100);- 20 replies
-
- 10
-
-
If you have latest LanguagePageNames, and you have set the home/root page the names "en", "de" and "fr"...? You can access the root name through the root page name. $lang_segment = $pages->get("/")->name; From anywhere in you templates no matter what sub page. But maybe with this setup isn't really save, if you don't have those names set or the default would have no segment name, it's not as reliable to assume it is set. But you could get around it. Better you just get the current user language in the front-end, since this is automaticly set by the language names module. This will have the language name that is set in the language support. Since default name can't be changed you have to get it like this to set default language code. $langCode = $user->language->isDefault() ? 'en' : $user->language->name;
-
ModuleJS won't append my script AFTER jquery core
Soma replied to Rob's topic in Module/Plugin Development
<?php class PageEditFoldStatus extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Page Edit Fold Status', // printable name/title of module 'version' => 0.1, // version number of module 'summary' => 'Uses cookie to remember fold status of fields on page edit', // 1 sentence summary of module 'href' => '', // URL to more information (optional) 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookAfter('ProcessPageEdit::execute', $this, 'hookPageEdit'); // make sure we the request is from backend as ProcessPageView is used for all page views if(strpos($_SERVER['REQUEST_URI'], $this->config->urls->admin) !== 0) return; $this->addHookAfter('ProcessPageView::execute', $this, 'triggerScript'); } public function hookPageEdit() { $class = $this->className(); $this->config->scripts->add($this->config->urls->$class . "js/jquery-cookie-master/jquery.cookie.js"); } public function triggerScript(HookEvent $event) { // only go further if we are on page edit process if($event->process != "ProcessPageEdit") return; $script = <<< _END <script type="text/javascript"> //...JS code... </script> _END; $event->return = str_replace("</body>", $script . "</body>" $event->return); } } This should do it. Forget about ModuleJS. Jquery core script is added in the admin.php process controller, so if you use ModuleJS or an init function of a Wire Module it will always get added before jquery core. So only way to add is through an autoload module with a hook on a other process or inputfield module. To render a script into the html, you need a hook to something that returns some rendered markup. Then inject it with a str_replace. Or you could hook into the ProcessPageEdit::buildForm and append a InputfieldMarkup with the script as the content, that will then get rendered with the form. Edit: changed Wire to WireData and added check to only add hook if on a backend url -
willyc, nope. it's not in modules directory yet!
-
How to set text line/character limits in templates?
Soma replied to photoman355's topic in General Support
I think you mean something like this: function wordLimiter($str, $limit = 120, $endstr = '…'){ $str = strip_tags($str); if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $out .= $endstr; } echo wordLimiter($page->body); -
hi kixe Good to hear you stay with PW and making progress. What approach are you using for multilanguage? Separate tree or same page with language fields? Well as you might already found out, language on front-end is default as user language has no effect apart from the backend. The url is the starting point for your php script to define what language is accessed and you then set the $user->language according. So if you have language segment domain.com/en/ you get the first segment to read what language the user accesses. When using the new language page names module this is done automatic. So the only thing you need to to is a language switch so the user can change language. I've seen you posted also in the language page names module thread... the last example of Ryan is currently the most easy way (requires latest dev version).
-
Has come up a cuple times http://processwire.com/talk/topic/546-how-to-detect-an-empty-field/
-
You could either just wrap the whole in a form, don't see any problems to do so even if the form fields are just in one tab. Have a separate process executeUpload() where you build the from.. and have a button with the href ="upload/". Or simply add a wrapper yourself (You can't just use InputfieldWrapper as a main wrapper with a ID, or I don't know how because it's not for such purposes) and use a main IntpufieldWrapper to render the wrappers... In a process module execute $wrapperMain = new InputfieldWrapper(); //...add all tab wrapper to the main. return "<div id='MyTabs'>" . $wrapperMain->render() . "</div>"; Then the js would be as simple as $(function(){ $t = $("#MyTabs"); $t.find("script").remove(); // to avoid double script execution $t.WireTabs({ items: $("#MyTabs > .Inputfields > .InputfieldWrapper"), id: 'ProcessExampleTabs' }); });
-
while(youcan < youshould) { // do what you want } Well use foreach... It's just a matter of preference and you could even use for() foreach() while() A while loop with a PageArray would look like this: $res = $pages->find("template=somexy, limit=10"); $i = 0; while($r = $res->eq($i)){ echo $r->title . "<br/>"; $i++; }
-
http://processwire.com/talk/topic/1593-how-can-i-specify-default-value-for-certain-input-field/ http://processwire.com/talk/topic/2199-checkbox-default-value/ http://processwire.com/talk/topic/394-default-field-value/ http://processwire.com/talk/topic/2460-possibility-to-pre-select-a-page-field/ There's more about that subject and it's not always around options but also on text fields etc. Maybe this is also interesting in your case: mods.pw/3b
- 8 replies
-
- radios
- page field
-
(and 1 more)
Tagged with:
-
It's not always good practice to have default value set for various reasons and there's some discussion about it in the forums. You have "normal" .. is it really needed to have that as a selectable state? All default entries are "normal" and should be handled in template code. Just create option with dropdown (as radios have no blank) and have "important" and "very important" as states.
- 8 replies
-
- 2
-
-
- radios
- page field
-
(and 1 more)
Tagged with:
-
The feature is already there. Look niks post. ;-)
-
Unable to complete request... no error log, debug or email.
Soma replied to Fourjays's topic in General Support
Pulled from github? Are really all files being pulled? "Unable to complete this request due to an error." And no error logged even with debug mode on? Are you sure? That sounds strange. Looks to me like some files are missing or corrupt maybe? Or cache? -
Page edit per user and template access, how do they relate
Soma replied to caribou's topic in Modules/Plugins
It's simple... "getAllowedTemplates" isn't hookable (just read that philipp made it hookable... sorry) That sentence doesn't make much sense to me... (as some of my own sometimes ) -
$pages->get('name=$name'); $name won't get parsed. You need in this case have double quotes "name=$name" or PHP doesn't replace $name with its value.
-
Select field values not getting edited in front-end form
Soma replied to onjegolders's topic in General Support
Ah ok just looked at source again and it seems it doesn't matter if output formatting is on or off... $page->invoice_terms = (int) $input->post->edit_status; is correct (for single page field), if the edit_status is the id of the page you want to add. Is practically the exact same as doing... $editTermsId = (int) $input->post->edit_terms; $page->invoice_terms = $pages->get($editTermsId); just this is having an additional not necessary db query. $pages->get($editTermsId) will return the id again.- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
Soma replied to onjegolders's topic in General Support
If output formatting is off, it doesn't matter.- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
Soma replied to onjegolders's topic in General Support
If it's a multiple page field (or no output formatting!) you just do $page->invoice_terms->add((int) $input->post->edit_status); add() works with page array, page or id's- 24 replies
-
- 1
-
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
@jmartsch, I think you encounter the same as the previous poster? is openssl installed? I just pulled in an update from petsagouris with multitude of changes, one of which checks for the openssl module being installed. udpate 1.0.7 - multitude of fixed and code cleanup (@petsagouris) - added check for openssl module required for https download stream (@petsagouris) - added back to Modules Manager button on download/update screen
-
Working with ProcessWire & getting EXIF data from images
Soma replied to MarcC's topic in General Support
Nice one Horst! I don't think you have to add the images_exif textarea to have it work. I thought the meta data function always gets called regardless, it's just that it only tries to write infos when that field is found. Second one is I pushed an silent little update to the FF bug with the tag field some time ago already.