-
Posts
803 -
Joined
-
Last visited
-
Days Won
10
Posts posted by kixe
-
-
//doesn't work
should work if called in a child page
//works
even if called from the page you are looking for
- 1
-
genious! and
$page->closest("parent={$page->rootParent}")
will work in bar1 and bar2 too. If you are using the same template.
PW API is a creative one.- 1
-
@Jan Romero
$page->parents("parent=$foo") //or $page->parentsUntil("parent=$foo")
will return a pageArray.
$page->closest("parent=$foo")
will include foo too.
$page->parent("parent=$foo")
yes thats the best solution. Never used this as a method. Thanks!
@matjazp
You should use Jan Romeros Solution like:$page->parent("parent=/foo/") // searching for the name of parent $page->parent("parent=1022") // searching for the id of parent
- 2
-
$page->rootParent returns foo of course.
$page->rootParent returns Home of course.this should work
$p = $page; while($p->parentID != 1) { $p = $p->parent; }
Edit: better: Jan Romeros solution (Thanks)
$page->parent("parent=/foo/")
-
@Marty Walker
Thanks for your debugging help. Everything fixed.- 1
-
@BernhardB & Marty
You can install the module via Soma's Modules Manager or download it manually and put it in the modules folder. This should work. I will try to fix installation with the 'Download and Install' option in PW.
1 hour later:I could fix it. Should work now. Thank you for reporting.
- 2
-
Have a look in the core module LanguageTranslator and in my module LanguageTranslatorPlus. You will find functions there to find translatable files and also something to extract translatable strings and also something to create jason-files. Make a new function to use bing Api and something to save.
If you put this together nicely it would be a useful module for everybody. -
or use processwire's new automatic page name feature (i'm using it a lot)..
@macrura
Ahh, thats what you are talking about
For everybody:
If you want to use this feature you have to create a new field of fieldtype PageTable.
'Automatic Page Name Format' could be set under the 'Input' Tab.
Since it is quite unlikely that the same page name is generated your example will work, but it is not a clean solution.Edit: Forget about the preceding line
I tried it out again and I have to correct myself again.
Not good, because you will get an mysql error if you do it more than one time
$page = new Page(); $page->parent = 'parentname'; $page->template = 'templatename'; $page->name = 'foo'; $page->save();
Better, because name will be autogenerated unique.
$page = new Page(); $page->parent = 'parentname'; $page->template = 'templatename'; $page->title = 'foo'; $page->save(); // or $page = new Page(); $page->parent = 'parentname'; $page->template = 'templatename'; $page->save();
-
processwire's new automatic page name feature (i'm using it a lot)..
$page->name = uniqid();
@Macrura
This is not processwires new automatic page name feature. It is a php function which generates a hex converted string of microtime().
Since it is quite unlikely that the same page name is generated your example will work, but it is not a clean solution.Edit: Forget about the preceding line
If you want to generate a page by processwires api with a unique page name, you
have tocould use the add() method. No need to instantiate a page object in your template.$parent = 'parentname'; $template = 'templatename'; $name = 'foo'; $pages->add($template,$parent,$name);
With this function you get pages with the title 'foo' and the name 'foo-[n]'. [n] is a counter which makes the name unique.
You could add a fourth parameter to set other page properties like status or so. The fourth parameter has to be an array.
$pages->add($template,$parent,$name,array('status'=>1));
Even if you leave out $page->name = uniqid(); in your example the page will be generated unique.
In both cases the counter doesn't work properly since it counts all siblings and not only those with the same name.
- 3
-
And too bad about WordPress if that's what they are using. I don't think they even know about PW. I will have to have a talk with them sometime.
A cute devil in pub turns out to drop a clanger. Never get involved with the devil. I need more Smileys here - in the pub, like glass of beer or so. Back to serious discussion ...
-
No, just create an imagefield assign it to the template where you want it. Create your foto page and select multiple image files to upload in one step. Done!
1000? It will take a while ...
Cannot read anymore ... Maybe this is your friend:
http://modules.processwire.com/modules/process-batcher/ -
uaah wordpress
-
.... It can happen.
Yes, its not the biggest problem I have. But there should be a way to solve this.
ProcessLogin.module (v101) gives an error notice if an index.php file from an older pw-version is found in the root directory.
I played with this one too. I got 6 entries in errors.txt with the same message by one click.
Two is ok, but six is too much for the best CMS in the world, isn't it?
- 1
-
@Nico
yes you are right, otherwise it is nonsense. Pretty sure I will never use it ...- 1
-
I triggered it by installing and uninstalling.
This way of log writing (outside a try catch handler) is very rare in core. I found it here:
FieldtypeComments.module -> after creating a field of type Comments.
ProcessPageSort.module -> after a page has been moved or after sort settings has been changed under tab 'children'.
Could you please try out this and tell me if you get duplicated entries in messages.txt? Thanks. -
I don't know how the module works. But 'name' is a reserved word for the pagename, which is stored in database table 'pages'. It is not a field like 'title', which is assigned to the page. Try another word than 'name'.
some other reserved words, which cannot be used for field names:- created
- modified
- status
- sort
-
Consider that users, templates, permissions roles etc. are in fact also pages. Not a good idea to give editors the possibiliy to mess up this.
Follow Somas recommendation and build some additional custom datetime fields.
If you need the original values as initial value, you could do this in your template$page->of(false); $page->set('CustomFieldModified', $page->modified); $page->set('CustomFieldCreated', $page->created); $page->save(); echo $page->CustomFieldCreated;
-
During module development I've recognized a strange behaviour. Logfile entries in errors.txt and messages.txt are always created twice. This happened on different servers in different environments with different modules.
I tested it with this small module:<?php class Debug extends WireData implements Module { public function init() { $this->message(microtime(),Notice::logOnly); // same with $this->error() } } /*log file entries: * 2014-11-07 05:52:14 admin [...]/admin/module/ 0.43575100 1415335934 * 2014-11-07 05:52:14 admin [...]/admin/module/ 0.43575100 1415335934 */
whereas only a simple entry is generated when I provoke an error an catch it to log with exception handling.
<?php class Debug extends WireData implements Module { public function init() { try { foo($bar); } catch(Exception $e) { $this->error($e->getMessage(), Notice::log); } } } /*log file entry: * 2014-11-07 12:45:19 admin [...]/admin/module/ Error: Call to undefined function foo() (line 16 of [...]/site/modules/Debug.module) */
Happened this before anywhere? Any Experiences with that? Any Ideas? Couldn't find out the reason for that!
-
... got lost in crone Here is another one ...
cronjob for database backup. All Informations here:
github: https://github.com/kixe/CronjobDatabaseBackup
PW Modules: http://modules.processwire.com/modules/cronjob-database-backup/
- 9
-
Since I recognized a remarkable overflow of my trash bin I made a small module which auto delete pages sustainably from the trash after a period which can be set in module settings.
PW modules: http://modules.processwire.com/modules/cronjob-empty-trash/
Github: https://github.com/kixe/CronjobEmptyTrash- 12
-
@sforsman
If I understood mr-fan correctly, he would like it to be interpreted as a thousands separator - which it currently is not doing, entering "40.559" would result in "40.56" in the database (if configured to use two-digit decimal precision).
I think he doesn't want, but the module and/or system does it!
@mr-fanbut with more than 3 digits it don't round and set value to 40.559 without position after decimal point....
Did you try exactly 3 digits? or also more than 3?
Hey guys,
while playing around with it I get the following results:
40,558 => 40558 // comma thousands separator
40,5587 => 40.56 // comma as decimal separator
40.558 => 40.56 // dot as decimal separator
40,558.89 => 40558.89 // comma as thousand separator, dot as decimal separator
40.558,89 => 40558.89 // the other way round
-
Looks like a thousands separator. Check it with:
$locale_info = localeconv(); print_r($locale_info); /* output maybe? * * * Array * ( * [thousands_sep] => . * * //other stuff * ) */
You could change local settings with setlocale() to handle thousands and decimal separators or add the following line to the module
$value = str_replace(".",",",$value); // there is already something like this. Just uncomment and switch search and replacement string.
Would be nice to have an option in the module which sanitize the input depending on local settings. Or a config field in the module settings?
-
Added module which will do the job until it will be implemented in core.
http://modules.processwire.com/modules/process-module-license/ -
If you want to make license visible in your custom PW Installation, you could place the following few lines in /wire/modules/Process/ProcessModule.module
if(!empty($moduleInfo['license'])) { $hreflicense = (!empty($moduleInfo['hreflicense']))?" - <a href='$moduleInfo[hreflicense]'>".$this->_('read more')."</a>":""; $table->row(array($this->_x('License', 'edit'), $moduleInfo['license'].$hreflicense)); }
just behind this line (989)
if(!empty($moduleInfo['author'])) $table->row(array($this->_x('Author', 'edit'), $moduleInfo['author']));
Now you can set license Name and link to license page in your Modules Info like.
public static function getModuleInfo() { return array( // other settings 'license' => 'CC-BY', 'hreflicense' => 'http://creativecommons.org/licenses/by/4.0/' ); }
Would be nice to add this option to core.
- 2
$page->children()->has('slider');
in Getting Started
Posted
$page is always the current page