-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
Thanks Ryan for the note, I'm very well aware of the possible recursion as I've done quite a lot of those save hooks for various things. I'm using a $pags->skip = true or a $page->save("field") to prevent it usually. Anyway it's not a problem or the problem here. I stick with the addHookAfter Pages::save, as that's the only one that works correct as you said I also have no idea why saving parent in the hook when using the Pages::saveReady fails to save the page I'm editing. But I noticed a similar behavior already with those two, just the opposite, where Pages::saveReady wouldn't work but a Pages::save would. So something going on that's not consistent across hooks that maybe should, I'm not sure as I don't see all behind it as you might could. It's just that those things makes me wonder what really happened and leaves me in a dark room with a strange feeling. I'm not sure what else I can do or say so you can maybe reproduce it. It's something I think "should" work and is nothing very special. Let me know if I can help if you can't reproduce the not-saving issue.
-
Some heureka. Ok I know now where the <html> is coming from. I got a LinkAbstractor module I coded that replaced some things on loading-saving... $this->addHookBefore("FieldtypeTextareaLanguage::sleepValue", $this, "hookSleepValue"); $this->addHookAfter("FieldtypeTextareaLanguage::wakeupValue", $this, "hookWakeupValue"); In there I got some function to replaceDocumentIdsWithUrl() $doc = new DOMDocument(); $doc->formatOutput = false; $doc->preserveWhiteSpace = false; $us_ascii = mb_convert_encoding($str, 'HTML-ENTITIES', "UTF-8"); $doc->encoding = 'UTF-8'; // insert proper @$doc->loadHTML($us_ascii); ... return $doc->saveHTML(); But not sure how to prevent that. But will try around. Still the non-saving of the page i'm editing persists even when I turn off the LinkAbstractor and use addHookAfter and Pages::saveReady. As soon as I save the $parent. When I remove the $parent->save() it works, but I need to save the $parent as that's all what it is about. :/ Anyway I now will use Pages::save.
-
Thanks Ryan for stepping in. I'm not sure it has to do with the server. The <html..> I'm getting is loaded from the "absatz" pages AFTER saving. And in DB it's not there. As soon as I change the hook to Pages::saveReady the <html..> wrap isn't there anymore. I also thought is has to do with the TinyMCE but not sure. It get's even more odd that when I add the string to the $this->message() it actually isn't there! Crazy. It's soo strange as I'm loading the body from the saved page and not from a POST or anything. But I'm not sure what I can do to find out. Really strange thing with getting logged out when using html_entity_decode. So I also thought some security thing is happening. But I'll have to ask the server support to make sure. After all, I would have get it working, it's just now that the "absatz" page I'm editing isn't saved anymore as soon as I use Pages::saveReady and $parent->save(). Kinda a lock I'm in.
-
This is the current code: protected function hookAbsatzPageSave(HookEvent $event) { // saved page $page = $event->arguments("page"); // only for pages with "absatz" template if($page->template->name != "absatz") return; $parent = $page->parent(); // to make sure setLanguageValue is working when saving page on front-end $parent->of(false); $allchilds = $parent->children(); // loop each language foreach($this->languages as $lang) { // start empty for this language $parent->absatz_text_index->setLanguageValue($lang, ""); $new_text = ''; // loop all children and collect texts for this language foreach( $allchilds as $absatz ){ $absatz->of(false); $body = preg_replace('#<[^>]+>#', ' ', $absatz->body->getLanguageValue($lang)); $new_text .= trim($body); $boxtext = preg_replace('#<[^>]+>#', ' ', $absatz->boxtext->getLanguageValue($lang)); $new_text .= " " . trim($boxtext); } // save the text to the on parent page for the language $parent->absatz_text_index->setLanguageValue($lang, $new_text); } $this->pages->save($parent,array("quiet" => true)); } @martijn no it's all correct, just loop all child pages and collect them and save the text to the parent. The text on the parent is saved correctly. Edit: I think I got some fault you might was right, but corrected now, just am changing stuff forth and back, sorry. But It has nothing to do with the odd things I'm having.
-
Thanks Wanze, not it's not. I somehow located the issue why the "absatz" page that triggers the hook doesn't save and its because of when I save the parent... $this->pages->save($parent); I tried all variations and no luck, as soon as I remove it the page I modify saves correct again. As soon as I add the $parent->save(); it doesn't save anything anymore to the page I'm editing.
-
I removed it meanwhile, as I think I understood it wrong, but doesn't make any difference at all. I just can't to get the page getting saved anymore when using addHookBefore("Pages::save",...) or addHookAfter("Pages::saveReady"...) , although the session says yx fields have changed and page is saved, but actually nothing gets saved.
-
Hmm, now it's just that the Page I'm saving that triggers this hook, doesn't save any changes.
-
I now tried changing the hook to hook after Pages::saveReady instead of Pages::save and you know what, it solves the <HTML> tags and Umlaute problem...(!?) I'm not understanding how this could make a difference. I think I've run into a similar strange issue when using Pages::save that when switching to Pages::saveReady solved it. Ryan? This is the complete code: $this->addHookAfter("Pages::saveReady", $this, "hookAbsatzPageSave"); And the Method: protected function hookAbsatzPageSave(HookEvent $event) { // saved page $page = $event->arguments("page"); if($page->template->name != "absatz") return; $parent = $page->parent(); $allchilds = $parent->children(); $lang_save = $this->user->language; foreach( $allchilds as $absatz ){ foreach($this->languages as $lang) { $this->user->language = $lang; $parent->absatz_text_index = ''; $body = preg_replace('#<[^>]+>#', ' ', $absatz->body); $parent->absatz_text_index .= trim($body); $boxtext = preg_replace('#<[^>]+>#', ' ', $absatz->boxtext); $parent->absatz_text_index .= " " . trim($boxtext); } } $this->user->language = $lang_save; $this->pages->save($parent, array('quiet' => true)); } Ignore the logic and quality of what I do here, it's just a workaround to get text from child pages to a parent page for easier searching pages. ---- BTW: Also wanted to note that I noticed when using TinyMCE and saving page without changing anything in the text it still throws message that body has been changed. Not sure what's about it and I think it is just confusing and has nothing to do with this I experience here.
-
I have a module that hooks after into Pages::save. I then read text from the page (multilanguage) to save to another page's text field. So using the getLanguageValue() like this: $text = $page->body->getLanguageValue($lang); $otherpage->setLanguageValue($lang,$text); The body is a textarea TinyMCE field with HTML option turned on, and the target field just a textarea field. However the text is save to the field but in a strange format like: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><h2>Kontrolleure, Polizei & Video</h2><p>Auch für VPT-Zentralpräsident Kurt Nussbaumer ist Videoüberwachung «in der heutigen Zeit das einzige Mittel, um Gewalttaten, Aggressionen und Vandalismus einzudämmen. Parallel dazu muss aber die Bahnpolizei regelmässig eingesetzt werden.» Vor allem in Problemzügen sei eine verstärkte Polizeipräsenz unerlässlich, d... How does this come to be? Edit: I'm going crazy with this! Something that should take me a couple minutes is going to take me again hours... As you see, also the umlaute are converted. I tried workaround this with strip tag and I did tried a html_entity_decode(), but as soon as I run it I get logged out (!) after it gets to the first ü.... wtf. Anybody have an idea what is happening? Even after trying this I get just logged out! $table = get_html_translation_table(HTML_ENTITIES); $rev_trans = array_flip($table); $complete_text = strtr($complete_text,$rev_trans); How can this be?
-
Yeah I think that was it. Just tested and seems to work. Thanks!
-
I seen this a couple times here by Ryan but can't find it. There a method to save a page silently so it doesn't update modified or user when saving a page. Was it $page->save(false) ? Anyone remember?
-
NO problem, you be blown away again then...
-
You can even make columns with fieldsets. Tabs and fieldsets are just special fields you create that are actually two fields one for open and one for closing. PW creates the closing *_END automaticly. You then add them to the template and wrap fields with them. You also only need to add the opening fieldset/tab field and after saving PW will automaticly attach the _END field too. I'm surprised so many people miss them, as they are also in the field dropdown when creating fields. FieldsetOpen, FieldsetTabOpen.
-
It's a special page, not a regular page you edit, with a system template "language". So you want to filter for "Show system templates" on the admin templates list or you don't see it.
-
Why do you need a band_title? Couldn't it use just title field? No, you have to add them manually. But generally you would want to reuse fields as much as possible for various reason anyway. You don't need a new textfield for every different type, keep in mind you can set label and description, visiblity in template context aswell, so a title could be labeled "Band Title" on a "band" template. There's a Fieldtype Cache that is not installed by default, that allows you to add multiple text fields that will cache them to "one" field allow you to search the cache field.
-
Silly problem: How to move page across page boundaries in the backend?
Soma replied to joe_g's topic in Getting Started
There's a more link at the bottom of the list. Usually not something you sort manually for such long list. Also you can set the limit in the page list module. -
I see this here too, and I'm seeing this behavior for all text fields, so nothing to do with this module.
-
Looks a little uneccessary complicated. I'm not sure I understand your code and what is "labelFieldName"? You already got the field name "related", which has nothing to do with the label of the field. You can also just use attr(key,value) instead of setAttribute(key, value) To recap you opening example: $category = $fields->get('related'); $field = $category->getInputfield($page); $field->attr("value",$page->related); echo $field->render();
-
In latest dev? Cause theres no line 232 in wire.php code that would produce this error.
-
I want comic sans for the new admin theme
-
250 is just a lot. I guess it would take with only outputing titles 1-2 seconds. And how many images are there then if count() takes so much time? $images->count() is another one but same like count($images) I guess. If you really need to do that for such a long list (!) you maybe better of caching it, like saving it to a text field or checkbox if there are images. You could do it after saving a page with a simple hook. So you could check with if($p->has_images) ... Or even cache the whole html to a textfield etc. Already lots of suggestions. Pagination wold be of course the most natural solution as suggested, but not sure what you're trying to do with a list of 250+
-
multi-column checkbox display via API not working
Soma replied to Peter Falkenberg Brown's topic in API & Templates
I guess you need also some of the inputfields.css and maybe main.css of the admin. Look for some *ColumnWidth classes. Also maybe worth mentioning that some of the admin css only works when you have your content in a ".content". -
You have the value already with the $page->related or not? $inputfield = $category->getInputfield($page); $inputfield->attr("value", $page->related); ... This way you populate the inputfield
-
What field? What version?