Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. Hey folks! I'm working on a couple new things for the TinyMCE inputfield in PW to extend it's capabilities toward using third-party plugins and html snippet templates (part of tinymce already). The thing is, until now you can only implement those stuff if you change the core distribution of it. Not any longer! I worked out a simple config setup that will give you all the freedom to use it on a per field basis even. So you could setup various templates or plugins for each TinyMCE field separate. For those interested in checking it out and help testing, I attached a folder with a updated "inputfieldTinyMCE" folder, and additionally added a "tinymce" folder which can be put where you want, but would suggest to put it in your /site/ folder. InputfieldTinyMCE folder is the one in /wire/modules/Inputfield/.. replace it with this new one. The tinymce folder contains some files already. plugins > - bramus_cssextras // advanced custom styles/ids via content.css template > - body_template1.html - content.css - body_templates.js The "bramus_cssextras" plugin is a great third-party plugin: http://www.bram.us/p...amus_cssextras/ I included this as an example how to load third-party plugins. And I use it in all PW projects already. "body_templates.js" is where you can specify templates which will be available, you then only specify the path to this in the custom field settings, it is like a proxy with an array of templates. It could be even a .php file! This is part of TinyMCE and documentation can be found here: http://www.tinymce.c...Plugin:template . To use template you also need to add "template" button and "template" plugin to enable it. "content.css" is the css you can add the path to this also in the advanced field settings. I would really appreciate any help with testing! Feel free to try install any other third-party plugins (not tinymce core plugins), or test out templates. Also attached a screenshot of the field settings I used to test this all with this setup. Again in Text form: theme_advanced_buttons1: formatselect,bramus_cssextras_classes,bramus_cssextras_ids,|,bold,italic,|,bullist,numlist,|,link,unlink,|,image,|,code,|,fullscreen,|,template plugins: inlinepopups,safari,table,media,paste,fullscreen,preelementfix,template content_css: /site/tinymce/content.css Additional TinyMCE settings: template_external_list_url : /site/tinymce/body_templates.js Third-party Plugins: bramus_cssextras : /site/tinymce/plugins/bramus_cssextras PW-TinyMCE-setup-test3.zip
  2. Andrew, I don't quite understand. This has nothing to do with php at all. It's plain javascript. Nothing very special about it, just update the /wire/modules/Inputfield/InputfieldTinyMCE/InputfieldTinyMCE.js with changes I've done. I attached the file (github pull request just shows parts) for easy update if you want to try it before Ryan puts it in. Once done, you can put a configuration as in my previous post's screenshot. Create a folder in your site folder and use the path to that html template like for example "/site/templates-tinymce/mytemplate.html". Add the plugin string "template" and the button "template" into the appropriate fields. Done. No php at all. InputfieldTinyMCE.js.zip
  3. you can also do this: $image = $profile->images->first(); echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='{$image->get('description|name')}' />"; in PW you can also access values of fields using get(). Adding a | between multiple names will return the first populated behaving like an "or" operand. echo $page->get("headline|title");
  4. Ok I got it working so the core tinyMCE inputfield will allow custom configs with javascript objects like the "template_templates" uses [{..}] I just sent a pull request for Ryan. https://github.com/r...essWire/pull/92 This looks something like the following and allows to specify templates per field, and put templates where you want : (the last line in the screenshot is just testing... "force_br_newlines", trust me you don't want that true )
  5. Glad you figured it out! Mind telling what you did? Concerning this I was about to soon find a solution to add templates easier, and per field. Ryan recently added a custom css and a textarea for additional config for tinymce configuration. Where each line would be a key:value. Testing now I found that how it's done currently, it doesn't work with adding a "template_templates:[{ ... }]" config. Because it expects to be a javascript object and not a string to work correctly. I'm working on some js vodoo to make it work in such cases. Just need a better solution than I have right now. If this is done, adding "bramus css extras" to it will make it much more configurable out of the box. I hope Ryan is in for it.
  6. I use a tinyMCE inputfield copy in my site folder to do such stuff using the tinyMCE template feature. You can provide as much templates as you want ,and let's you select/preview one, then it will insert the html of the template. Template are just snippets of html and put in a folder as name.html files. You then define what and where they are using the config. http://www.tinymce.c...Plugin:template
  7. Alan, my code was just assuming things. Sorry if that confuses you. But your tag pages, uses a template for sure. No way around that. It's just that if you're doing a find over ALL pages in PW to look for a field with the name "mytag", it will not be as fast as if you limit the find to a template or even branch ( or it will possibly even find another page using the same name, thus creating problems) . That's all. It may doesn't matter in a 100 page website, but will with 1million pages.
  8. Yes! But I'm not getting which one? The one on the articles I guess. Try this: $tagpage = $pages->find("template=tag, name=$tag")->first(); // get the page that is the tag page itself $articles = $pages->find("template=article, tag=$tagpage"); // in case the tag on article is a page reference... you would change the template name to whatever your's are. It's good practice to limit it if you do a $pages->find(). Or better do, if you can, $pages->get("/tags/")->find(...);
  9. Global you shouldn't set, because it will add it to all templates I think. Just autojoin should do the trick.
  10. The reason for this is simple $pages->find("tags*=$tag"); doesn't work because "tags" field is most likely not fulltext field like "title", thus not working with *= . Try setting the field to "autojoin". Not sure though... gotta continue work. But hope this helps.
  11. Alan, if your tools page is hidden, you don't need to set all children of it to hidden. Usually we set a page hidden, to not show up in navigations. So it's basicly enough to have the parent set to hidden.
  12. Sorry guys, as this was my fault for not testing the bug fix with link editing through-out.
  13. I just commited an update, with improvements to simplify module code. Originally fixing an issue with "has_children" behaviour. Which now works also with custom selector (that would ommit pages by template) and max_levels as expected. It will now only append if there really is children to be shown. Also fixed and updated some documentation. Thanks
  14. I don't think there any over the other, at the end it is and does the same. Just a matter of preference.
  15. In a module it's not the same as in template level, in a module you use wire("input")->urlSegment1; $wire->input->urlSegment1; or $this $this->input->urlSegment1;
  16. Bill, if I look at your code I just keep thinking that I would do this. And look! Without foreach! $rand_children = $pages->find("template=basic-page")->getRandom(3); echo $rand_children; // returns 102|230|323 $ids = explode("|",$rand_children); print_r($ids); // array with id's ..so a one liner would be this: $ids = explode("|", $pages->find("template=basic-page")->getRandom(3));
  17. Try this without the $ in the field name? <?php foreach($page->Meta as $m) { echo "<meta name='$m->MetaName' content='$m->MetaContent' /><br/>"; } ?> or this with the {} <?php foreach($page->Meta as $m) { echo "<meta name='{$m->MetaName}' content='{$m->MetaContent}' /><br/>"; } ?>
  18. Hi gottberg! To include the root page you would pass the option "show_root" like: echo $treeMenu->render(array( "show_root" => true ));
  19. Pete, i think you want to use the markup cache in PW to do simple caching to your needs.
  20. Hey MadeMyDay! Thanks for your post and inputs. As a modx user myself (not anymore) I certainly know Wayfinder, but found it a little too overhelming with way too many complicated options, so I've never used it to it's full power, also because the basic output was always enough. Pete is right, if you want the ultimate flexiblity you would want to create your own nested function to output. But I guess it also can get complicated depending on what you want to do. Generating a basic nested navigation is really easy using PW API, but I like to have some sort of tool that suites for most cases without getting into too much coding everytime. So having a module like I see as a nice way you can always rely on for fast implementation. You're right that maybe best option would be to have classes appended to <li> element and not inner item. It will more easily allow for if you are styling <li> elements, but let's you as well style the inner element. The other way around it isn't possible. I'm always styling the anchor and not the list element as it is the most easy and reliable cross-browsers. That's why I implemented it this way. But it's now changed by default. I understand that having a possibility to define custom markup will make it even more flexible and I was already planing to do anyway. Though with such implementation it's always the case that at some point you're still limited at best in some way or the other. I already looked into it and found a easy implementation that will work and not having too much options. I just commited a major new update to github and updated first post to reflect changes. It let's you now define custom markup even with placeholders/tags for fields you want to output. Just as an example you could do something like this: 'outer_tpl' => '<ul id="mainnav" class="nav">||</ul>', 'inner_tpl' => '<ul>||</ul>', 'list_tpl' => '<li%s>||</li>', // template string for the items. || will contain entries, %s will replaced with class="..." string 'item_tpl' => '<img src="{icon}"/><a href="{url}">{headline|title}</a><p>{summary}</p>', // {icon} any image field will be auto-recognized and return image url instead. {url} will output url to document. Any other field will output normally (assuming it's a textfield) 'item_current_tpl' => '<img src="{icon}"/><span>{title}</span><p>{summary}</p>' I also renamed and removed some options with this update, so if you already using it, make sure you update your template code. Sorry for the inconvenience it may cause. But I think it is now better and will not change in future. Changed: 'class_current' to 'current_class' 'class_parent' to 'parent_class' 'css_levels_on' to 'levels' 'css_firstlast_on' to 'firstlast' Added: 'has_children_class' => 'has_children' 'levels_prefix' => 'level-' 'outer_tpl' => '<ul>||</ul>' 'inner_tpl' => '<ul>||</ul>' 'list_tpl' => '<li%s>||</li>' 'item_tpl' => '<a href="{url}">{title}</a>' 'item_current_tpl' => '<a href="{url}">{title}</a>' Removed: 'ul_class' and 'ul_id'. Which now can be added via 'outer_tpl'. While at it I also fixed a max level issue when using other root page than "/". Thanks.
  21. It doesn't yet any cleaning up, even if you delete the images on page or even the field the images stay there. Only if you delete the page itself, they will get deleted.
  22. Have you tried doing a table/db repair?
  23. Thanks for the fixes! They all work now. Hope the clone issue will not be too much work
  24. No it's gone, guess it was a cache problem. Only happened first time. Thanks!
×
×
  • Create New...