Jump to content

Sinmok

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by Sinmok

  1. I don't suppose there's a way to access the protected data array within the PageArray object?
  2. Don't know if you can already do this, but implementing PHPs array_chunk method would be pretty useful.. For example $list = $pages->find("template=something"); // Returns 5 pages $chunked = $list->chunk(3); print_r($chunked); /*prints*/ array( 0=> array( Page, Page, Page ) 1=> array( Page, Page ) ) Especially useful if you're trying to print pages into columns. Can you already do this?
  3. How do you clone the home page? There's no copy option. Does it have to be done via the API? Edit: Just tried cloning the homepage and setting the clone's parent as the homepage through the API and I'm getting an error saying I can't edit the ID of a system page =\
  4. Hi all, I need to switch out which page represents the home page. I have a lot of field data in the existing home page but have been advised that the home page needs to be swapped out for another existing page. Both pages already have a lot of data so re-doing them would take a lot of time and effort. Is there a way I can switch out the home/root page? I can't seem to move them. Alternatively, is there a way I can copy the home page? Then I could just call $pages->get("/")->home_page->render() in the home template without losing everything I've done. Cheers
  5. RT @jasonforal: Facebook is really taking its name too literally. http://t.co/Anqf4RCRnr

  6. What are the licensing restrictions on the CKEditor pwlink and pwimage plugins? I'm working on a new front end editor and the only thing that doesn't work is the linking and image selecting. I reckon i could get it to work by modifying the existing plugins to work with the module I am building instead. Am I allowed to do this? I don't see any license files Cheers
  7. RT @kevinmontrose: ~12% of all bitcoin created to date have been stolen. Wow.

  8. I should have been more specific. I don't know what the field is going to be. I need to iterate over the pages fields and then make a decision based on that. For example: $page = $event->object; if($page->template == 'admin') { return; } $fields = $page->fields; foreach($fields as $field){ $this->setup($page,$field); } However, within setup I try protected function setup($page, $field){ if($conditional_logic){ $page->{$field->name} = "Some other value"; } } But I get the error Even though I can echo out the contents of $page->{$field->name};
  9. Hello all, Little stuck on how to override what a field outputs when being called within a template file. Take the following sample code inside a template: <h1> <?=$page->title?> </h1> <div> <?=$page->another_field?> </div> What I'm trying to do is analyse and potentially modifying the output of this field from within a template, using a module WITHOUT saving the page. This is currently the code that I'm trying to run public function init() { // add a hook after each page is rendered and modify the output $this->addHookBefore('Page::render', $this, 'exec'); } public function exec($event) { //Get the rendered page $page = &$event->object; if($page->template == 'admin') { return; } //As a test, try and modify the title field, but in the future I'll need to be able to modify any fields $page->set("title","A test title!"); } Unfortunately, this doesn't work. - The page still renders the original title within the template! Ideally - my long term goal is to know: What the field type of the called/rendered field is The current value of this field Any guidance is appreciated!
  10. Sinmok

    Hanna Code

    Is there any way to get Hanna code to render within Hanna code? I've got two tags. [[tooltip]] and [[info]] What I'm trying to do is this: [[tooltip text="[[info]]" tooltip="test"]] And then using the following snippet within the [[tooltip]] hanna code: $hanna = wire('modules')->get('TextformatterHannaCode'); echo "<a class='tooltip' href='#' title='{$tooltip}'>".$hanna->render($text)."</a>"; This doesn't seem to be working unfortunately. Any ideas on how to make this work? [[info]] just echos out an img tag. Cheers
  11. An example would be helpful, as I can't get a working solution with has_parent within find().
  12. Hello all, Probably a silly question..but I'm having trouble figuring out if a page is a descendant of another page. Let's assume I've got a page currently referenced as $section. I need to know whether $page (current page) is a descendant of $section, preferably returning a true/false value. Does anyone know how to accomplish this? Something like this would be solid: if($page->isDescendant($section)){ //$page is a descendant of the $section node } //OR if($section->hasDescendant($page)){ //$section is an ancestor of $page { EDIT: In the end, I got it working using the following code. $page->parents("id=$section->id")->first()->id == $section->id This is probably not the best of solutions though so I'm interested in hearing yours. Cheers
  13. Hi all, I'm wondering what the best approach is to add instructions to a template. For example, if you download the Hanna code module and click 'Code', at the bottom of the page there's a section called 'PHP and JavaScript usage notes' which contains instructions. Screenshot If I wanted to add similar instructions to a template of my own, how would I go about doing this? Cheers
  14. After quickly scanning through my own code (it's been a while..) I can safety say that the methods setupDiv and scripts do in fact check if the page is editable before returning anything. You should be fine using it without.
  15. Greetings all, Trying to figure out how I add extra attributes to an element in TinyMCE. When I make a piece of text a link, I get the PW popup asking for the URL etc, but there's no way to specify custom attributes for this tag such as a title attribute or even a data-* attribute. I've edited TinyMCE to allow the title attribute for <a> tags and they're not getting stripped out on save, but it is incredibly cumbersome to have to manually add these extra attributes to an element through the HTML source editor in TinyMCE. I need this functionality as I am using the title attribute to display a tooltip on hover for the <a> tag. Does anyone know of a plugin, module or anything really that would help resolve this issue? Cheers.
  16. Hey all, I know that this is an absolute long shot, but I was wondering if there was any way to include the Processwire API to the FuelPHP framework. I've included the index.php as documented on the docs here but unfortunately I get the following error: Obviously there's already something declared which is causing this error, but on the off chance that someone else has had a similar issue in the past..please advise on how you go around the issue! Cheers
  17. Hello all, I was wondering what the most elegant solution would be to find out when the last time a change was made to any regular pages (not admin pages)? Cheers. Update: Sigh was trying to overcomplicate things again. The easiest solution is: $page = wire("pages")->find("sort=-modified")->first()->modified;
  18. Hey, Didn't realise anyone was actually using this, and tbh I've not had the chance to update it in months. Adding an option to remove CKEditor + dropzone is a very good idea and when I eventually get round to to it, I'll add it in. Glad you're finding it of use though Cheers.
  19. I've just noticed something about this module. If you set the input required field to "Yes" and then try to save a page without selecting an option, it comes back with an error saying it's required..but all the values on the rest of the page still save. Is this a bug with this module or across the board?
  20. Hi all, I'm having an issue with getting fields to display on page creation. I've set a template to allow for only a single specific template to be used for immediate child pages. When a user creates a new child page, only the title and name fields are appearing for entry, even though it has recognised that the page has to be created with a specific template. Is there any way to get all fields associated with the new pages template to show, so that the user doesn't have to click the save button before filling in the rest of the form? Seeing as the system knows what template is, I don't see why it can't just display all the fields on creating a new page. Thanks!
  21. BBC News - British women attacked with acid in Zanzibar http://t.co/zqb05Oxd6H

  22. Hi all, I'm having an issue with the HTML source editor on both TinyMCE and CKEditor formatting. I have a few images that I've inserted into a content field but every time I try to add an inline 'style' to these images, the style is automatically stripped when I click 'update'. I need to be able to add inline styles to these tags. Does anyone know how to prevent the editor from resetting the tags to default when I click update? Thanks Edit: Figured it out.Open CKEditors config.js and add config.allowedContent = true;
  23. Why am I wearing a jumper in this weather?

  24. Sinmok

    Hanna Code

    No no, not TinyMCE. Here's the SS from the modules page: In the 'Code' box, there's no syntax highlighting for the code that is in the textarea. I'm just suggesting that the code in the textarea has syntax highlighting as you type to help prevent users from making an error when writing their code in that box.
×
×
  • Create New...