-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
There's no field access yet, but I've heard rumors that it will come sooner or later. However you can create a simple module that does hide/show fields on a condition, whether a custom permission, role or user. Following is a simple autoload module that hooks the Inputfields and returns empty string, if condition aren't met. Actually very straight forward and powerful. There could be added some module configuration, to simply add fields via a textfield you want to hide for other users. Possibilities are endless. Save the code as FieldHelper.module and put it in /site/modules/ Configure it to your needs and install it. <?php class FieldHelper 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' => 'FieldHelper', 'version' => 100, 'summary' => 'Hide fields depending on permission, role, or user.', 'singular' => true, 'autoload' => true ); } public function init() { // add after-hook to the inputfield render method $this->addHookAfter("Inputfield::render", $this, "renderField"); } /** * Hide fields depending on permission or possibly role, user * */ public function renderField(HookEvent $event) { // get the current field $field = $event->object; // example 1permission if($field->name == "pre_content") { if(!$this->user->hasPermission("admin-fields")){ $event->return = ''; } } // example 2 role if($field->name == "after_content") { if(!$this->user->hasRole('superuser')){ $event->return = ''; } } // example 3 user if($field->name == "page_scripts") { if(!$this->user->name('admin')){ $event->return = ''; } } } } I created a gist for this example here: https://gist.github.com/3122191
-
should be ... $video->template->set('filename', 'teaser.php'); ... $template->setFilename() is protected.
-
Ok, I have implemented a language domains option you can now enable in the module settings. I did some testing on my local install and so far everything works as it should. I just commited the update and it's ready to use. urlSegments , pager, page links in language text fields still work and I didn't notice any problems. However it's not sure any other side-effects pop up I may missed, apart from the ones already there. From readme: This module now supports language domains. So you can have each language mapped to its own domain. To make this work you need to have the different domains point to the default domain and PW install. Then enable this option in the module settings and enter your domains in the textarea, each domain on its own line. The format is [domain:langcode] i.e.: domain.com:en domain.de:de domain.fr:fr You could also use subdomains: en.domain.com:en de.domain.com:de fr.domain.com:fr Result: Now you can access the different languages simply through the different domains. For example the "/about/" page would be available like this: domain.com/about/ domain.de/ueber/ domain.fr/au-sujet-de/
-
PW has also such a module that does what you're saying. http://processwire.c...ink-abstractor/ it's listed here http://processwire.com/download/modules/
-
The simplest way is to have the domain.com point to domain.de. Done. Now it depends on how you create the language switch. Just adding the domain in front of the url would be enough. But you will end up having domain.de/de/.. and domain.com/en/... The module has an option to hide default language folder, so /de/ will not show. But for alternative languages there currently no way, without adding anther option to hide them all. Let me know if that would for out for you, and I'll try to implement it.
-
Testing for the first element in a wirearray
Soma replied to thetuningspoon's topic in General Support
I think in this case correct would be == not === but both will work. There's some coverage of it here http://www.php.net/manual/en/language.oop5.object-comparison.php There seem to be a case when testing with "==" when "===" should be used to indentify objects can result in a overhead that could be avoided. Not sure what really is the better option id==id or object===object. Maybe someone else can tell better. -
Testing for the first element in a wirearray
Soma replied to thetuningspoon's topic in General Support
Thanks arjen for posting this. Well it has nothing really to do with the while loop it's just another variant. It can be done with a foreach or for loop $newsItemList = $page->children; $cnt = 0; foreach($newsItemList as $news) { $cnt++; if ($cnt == 1) { // do stuff } else { // do stuff } } -
Hi and welcome. Thanks for the report. I'm sure Ryan will soon comment, as I think he's the one really knowing what's going on.
-
Testing for the first element in a wirearray
Soma replied to thetuningspoon's topic in General Support
Always forget about it but thought I'd mention it. You can also use if( $newsChildPage->id == $newsChildrenArray->first()->id ) { ... which is even better and should be faster although not sure how much really. -
A example code how to set a templatefile on runtime $t = new TemplateFile($config->paths->templates . "./another.php"); // send vars explicitly possible // $t->set( "somevar", $somevar ); // $t->set( 'input', $input); echo $t->render(); However I think you might like the template option i the advanced setting to use another template instead. Also your example works using the render method of a page. Have a template video.php that includes teaser.php. Then use your example code as is.
-
Testing for the first element in a wirearray
Soma replied to thetuningspoon's topic in General Support
The problem lays in the if( $newsChildPage == $newsChildrenArray->first() ) { Comparing object shoudl be done using "===" Not sure why the error, but with "===" it works. However I cleaned up a little your code, using heredoc (<<<_END) which can be handy to generate output code so the indentation stays. foreach( $newsChildrenArray as $newsChildPage ) { $newsImg = ''; //Test for an image on the current page if( count($newsChildPage->images) ) { //If this is the first article, make a larger image if( $newsChildPage === $newsChildrenArray->first() ) { $newsImg = $newsChildPage->images->first()->size(157,151); } else { $newsImg = $newsChildPage->images->first()->size(77,71); } } $class = ''; $imgstr = ''; if( $newsChildPage === $newsChildrenArray->last() ) $class = ' class="last"'; if( $newsImg ) { $imgstr = "<img src='{$newsImg->url}' alt='$newsImg->description'/>"; } $out = <<<_END <a href="{$newsChildPage->url}"> <li$class>$imgstr <p> <span class="preview-title">{$newsChildPage->title}</span> • <span class="preview-date">{$newsChildPage->date}</span><br /> {$newsChildPage->summary} <a href="{$newsChildPage->url}" class="read-more">Read More...</a> </p> </li> </a> _END; echo $out; } Also changed some things to avoid further problems. Using ->eq(0) for example to check if there's an image is wrong. It won't work if there no image. Use count(); Also the check if($newsImg) will fail if there's no image as the variable won't exists. So you need to set it before. -
Project and Category Architecture for Portfolio Site?
Soma replied to Lance O.'s topic in General Support
Selfsupport! Brillant! -
Something I noticed when using this module. When I use the $page->render() method for the proxy template. I have a auto hook on Page::render that add in some script before the body end with php string replace. For some reason it's getting executed 2 times resulting in duplicated code. I'd guess the page rendered with ->render() in a template causes the system to render it twice? Edit: This is used in the proxy template $page = $modules->get('LanguageLocalizedURL')->parseUrl(); echo $page->render(); And using this hook to str_replace html $this->addHookAfter('Page::render', $this, 'addScripts'); So I have to add this to check if already there // if already there (in case of using $page->render()) if(strpos($event->return,$script) !== false) return;
-
Ok I just pushed an update. You can now disable transitions. I will at some point hide the additional options in a hidden settings layer. I will still have to see what I'll do with additional stuff. I also see adding some that's left off in the same sheet and give them a color code like advanced. Adding additional sheet that can be switched would aslo be nice, but not as trivial as it seems.
-
I'm kinda with Ryan. I really like the animation and it has the right speed. It depends a little on the browser as it's done with css transitions. Making it even faster will not help but make choppy (depends on how many elements are animated). But I agree it would be nice to turn it off if one likes. So it is very easy to add another option to disable it. Will push an update later.
-
One small correction: Cufon Canvas,VML depending on the browser from which it generates a base64 encoded png image for each word. In Firefox right click will show it's an image. Enter code in address bar and you'll see the image: data:image/png;base64,iVBORw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C When you scale a website with cufon for text, you'll see the pixels.
-
"The emulator is super simple to install and lets you do serious mobile development from your desktop." So far none of the emulated devices shows/works the same as with the real device. Some more or less. I wouldn't rely on emulators at all for serious developement.
-
Also consider to write a script that checks all textfields (tinymce textareas) where link could be inserted, to check links and or modify them as needed in one click. Either use simple_html_dom.php class or using some regex. Other thing I would consider is adding such links using a tag {url:somekeytext} and replace them with a script before the output. This could also be maintained using a "page" with all the links in a repeater with tag and url that will be used for the replacements. Some module hook could maybe even add them to tinymce or its field description for reference.
-
Have you deleted cache and maybe cookies? Looks and works fine here. What OS?
-
Thanks for the feedback. Yes I know, but I don't know a way to turn it off because it's doing what it's supposed to Well it doesn't happen often, so I can live with it. One way to get around it would be to make the description hover. I tried something but there's some issues with indexes and would complicate things or would have to add another tooltip like functionality. But got so used to the toggle slide and like it so far.
-
I've been working for some time on an updated version to functionality of the cheatsheet and have commited it now. All code and functionality, no content changes. removed table layout and added the excellent Masonry/Istope js for block layout and filtering added setting for column count so you can change it to your best fit in the toolbar improved live search, especially in Firefox (which wasn't really working before) now sections not containing any filter results will be hidden (not get in the way anymore) These changes also will help adding more content to the sheet. Preparing to launch the rocket! Enjoy.
-
Nope Peteee, it wasn't working when using single value slider, a missing semicolon will break javascript if it's not the last line
-
Don't know if you know this module. Maybe something like this would help?
-
Thanks tiagoroldao, nice catch! Seems as not much are using it yet, otherwise someone would have run into this. Though it worked with range enabled. Well, you can always open new issue on github repo. It's public. https://github.com/somatonic/RangeSlider/issues It's fixed and commited. I also improved the module install. You only need to install the FieldtypeRangeSlider and the InputfieldRangeSlider will be installed and deinstalled automaticly. If you already have it installed it's safe to just replace with the new files.