Jump to content

Rob

Members
  • Posts

    134
  • Joined

  • Last visited

Everything posted by Rob

  1. I'm on 2.1, just so you're aware. I guess we'll see if I get weird behaviour another day!
  2. I'm interested in these ideas too. I like the CMS back-end of PW but I'm not so keen on the way it essentially drills down to a file that just spits out content. I would prefer an architecture thay is more like a pyramid whereby the index file dispatches based on the URL, fetches the data and returns the content and header in an object back up to the starting point (the index.php again) where it is handled appropriately. It seems like this might be possible if I can just have a rewrite rule that redirects anything non-cms to my own secondary index file where I can use the API to handle it in the way I would like e.g. much more like a modern MVC framework such as Symfony2. I'm using TWIG for templating but this is just the start.
  3. Ryan, good news!! http://www.tinymce.com/wiki.php/Configuration:theme_advanced_styles I basically added 'theme_advanced_styles' to the $defaults variable in the TInyMCE inputfield code, and this added another field to the advanced field config. If you read the above link you'll see the format required, basically a seried of name=value pairs separated by semicolon. It works a treat. Probably needs a few more checks to make sure it's bulletproof, but it basically works fine as far as I can tell.
  4. I totally missed those settings, seems fine now. I'l have to find out where the other styles already in content.css are being used, I'd really just like styles of our own choosing in the select box. I don't want editors being able to align text, this is a design nightmare waiting to happen!
  5. It seems that the settings in 'theme_advanced_buttons1' element of $defaults variable in InputfieldTinyMCE doesn't have any effect on anything. I also tried tweaking the settings in the JS file but that didn't help much. The reason I implied "non-standard" is that I can add the styleselect by changing 'theme_advanced_buttons' element of that $defaults variable but nothing happens with changes to 'theme_advanced_buttons1' so I assumed it was being ignored in favour of hard-coded settings elsewhere. I've used TinyMCE before (although some years ago) and it wasn't a problem to get a style dropdown then, thus my confusion.
  6. We have a requirement to have custom style dropdown in wysiwyg editor. This should be straightforward according to TinyMCE docs but it looks like the way TinyMCE is used in PW is non-standard and so what I'm doing isn't working. The wysiwyg inputfield code suggests that the styleselect dropdown should be visible in the first (and only) row of buttons, but it isn't. If I edit the config for second row of buttons I can get it to appear, but I'd rather just have it next to the block format dropdown where it should be! Is this possible without enormous hackage of the module code?! Thanks.
  7. I was going to move my folders around so that the only bits that have public access are the minimum assets (images, css, js etc) and the index.php - am I right in thinking I can move it all around as long as I set the various location variables in index.php correctly? I'm still only developing locally at the minute, but I want to be sure I can do this when it goes live, it's not a good idea to have the entire installation underneath the public web root.
  8. I've been thinking about ways to integrate some image management into PW for our new site build, and here are the options I've come up with so far: - 1. Image template type, with a simple image field and tags field. So basically adding a new page for each image. Unfortunately, this is painfully slow for adding many images, and using pages as objects for generic storage might not be scalable or sensible in the long run. 2. Develop an image repo module. This is no doubt plausible, but also complex with my current level of experience with PW. I think that might be biting off more than I can chew right now. 3. Extend image fieldtype to have a tags field (as well as image itself and description) and then have a single page with single images field where images can be added, tagged etc. These images can then be filtered/pulled into other pages with the API. Does the third option sound plausible, and would I be entering into a world of pain with scaling issues? Also, once the images ran into hundreds, would the interface for adding/removing be awful? One endlessly long page? Ultimately I guess lots of potential/current PW users need some sort of media management functionality, but I may not be the man to build it. Not yet anyway!! Thanks in advance.
  9. Code mistake again!! In fact, all I had to do was remove the code that checks for an array and returns (thus not allowing multi-dimensional arrays) and I now get the behaviour I would expect. This brings me back to the question - why disallow this behaviour?
  10. My bad - that code isn't fully recursive, but it certainly allows me to have an extra dimension in my field name arrays. I'm sure I'll get told shortly why this isn't a good idea!!
  11. If I make WireInputData::cleanarray() recursive by removing the check for array line and then adding this... If(is_array($value)) return $this->cleanarray($value); ...then I get the result I would expect. Is this behaviour likely to damage other parts of the system?
  12. I've been developing an Inpuitfield/Fieldtype combo that allows me to input multiple sets of data, and I'm using JQuery to add another "set" of data into the form markup but I've run into a problem becasue I'm using multi-deimnesional array names for the form fields. This doesn't get processed correctly by PW and when I look at the WireInput class it mentions only allowing single-dimensional arrays. Is there a good reason for this? Multi-dimensional arrays in forms are pretty useful and I can't work out (off the top of my head) why this would be restricted in this way. For example: <input name="fieldname[phonenumber][] /> <input name="fieldname[phonenumber][] /> This will return an empty array for the field value in the WireInput instance passed into ___ProcessInput() method. Is there a specific reason? I can manage by directly accessing the POST array, but it'd be nicer to use a native PW approach.
  13. Right, they've just shown up, but Ihad to delete some files from site/assets/cache. The filenames started with Module I think. Is there a setting I can change so I don't need to do this manually?
  14. Ryan, I have a file called 'InputfieldLinkMultiple.module' inside '/site/modules/InputfieldLinkMultiple' and a file called 'FieldtypeLink.module' inside '/site/modules/Fieldtype'. Class InputfieldLinkMultiple extends Inputfield implements InputfieldHasArrayValue {...} Class FieldtypeLink extends FieldtypeMulti {...} Both have getModuleInfo() and I assume have init() from the resepective superclasses.
  15. Hello forum, I'm wondering why my Inputfield and Fieldtype I'm developing won't show up in the module list. I wrote simple "single" Fieldtype and Inputfield classes last week and got them to work properly, but now I am trying to create a "multi" type Inputfield and corresponding Fieldtype and they don't seem to want to show up in the module listing. In other words, my Fieldtype is extending FieldtypeMulti. My Inputfield is just extending Inputfield top start so I can learn to render the correct form markup etc. Are there a minimum set of methods that I need to implement for them to be valid? I'm trying to compare them to existing Inputfield and Fieldtype classes to see if there's anything obvious. Thanks.
  16. Right I think I've finally cracked it!! I had to write a custom processInput() in my custom Inputfield because, for some reason I couldn't figure out, it wasn't correctly populating the underlying fieldtype object with the posted value so I had to do it myself. <?php class FieldtypeFXProductList extends Fieldtype { public static function getModuleInfo() { return array( 'title' => 'Product List', 'version' => 001, 'summary' => 'Provides a dropdown list of products' ); } public function getInputfield(Page $page, Field $field) { $inputfield = $this->modules->get('InputfieldFXProductSelect'); try { $db = new Database(...); $db->select_db(...); $result = $db->query("SELECT product_id AS id, name FROM product ORDER BY name ASC"); while($row = $result->fetch_object()) { $inputfield->addOption($row->id, $row->name); } } catch(Exception $e) { echo $e->getMessage(); } return $inputfield; } public function ___wakeupValue(Page $page, Field $field, $value) { $db = new Database(...); $db->select_db(...); $result = $db->query("SELECT * FROM product WHERE product_id = $value LIMIT 0,1"); $data = NULL; if($result) $data = $result->fetch_assoc(); return $data; } public function ___sleepValue(Page $page, Field $field, $value) { return $value['product_id']; } public function sanitizeValue(Page $page, Field $field, $value) { return $value; } } ?> <?php class InputfieldFXProductSelect extends InputfieldSelect { public static function getModuleInfo() { return array( 'title' => 'Product Select', 'version' => 001, 'summary' => 'Selection of a single product from a select pulldown', 'permanent' => true, ); } public function isOptionSelected($value) { if($this instanceof InputfieldHasArrayValue) { return in_array($value, $this->value['product_id']); } if(!isset($this->value['product_id'])) return FALSE; return "$value" == (string) $this->value['product_id']; } public function ___processInput(WireInputData $input) { if(isset($input[$this->name])) { if($input[$this->name] != $this->value['product_id']) { $value = $this->value; $value['product_id'] = $input[$this->name]; $this->value = $value; $this->trackChange('value'); } } return $this; } } ?>
  17. Before I get to posting code Ryan, any thoughts on why sleepValue() wouldn't be getting called at all? If I put any sort of debugging code, dumping values out to the screen, call exit(), anything, it does nothing, it just carries on and claims to have saved the filed but nothing has been updated in the DB. It really seems like that method just suddenly stopped getting called. I'm banging my head against the table here, it shouldn't have taken me two days to get this custom field code written!
  18. I don't know what the hell I've done now, but now my sleepValue() method isn't being called at all!!
  19. Thanks Ryan. It seems that I had to create a custom Inputfield that extended InputfieldSelect in order to add the custom behaviour that preselects the saved value in the selectbox. Next problem - When I now print_r() the content of $value in the sleepValue() function of the Fieldtype, it is giving me the record is it currently is in the DB (as it would be since being loaded and passed through wakeupValue()) but it doesn't seem to have updated with the value from the post data. So essentially I can't overwrite the value in the DB. So my next thought is this - presumably I need to do something extra in my overridden custom Inputfield class to pass the posted value back to the Fieldtype object? Does that sound about right? Apologies for th constant stream of questions, I hope you don't mind!! I hope it will be a useful reference for others, and once I have it clear I may post some tutorials myself.
  20. Ryan, What isn't clear to me is when sanitizeValue() is called. If i put print_r($value) as the first line of my sanitizeValue() method then it dumps out an array because this is what is coming from my wakeupValue() method. This implies that sanitizeValue() is being passed the value from my wakeupValue() method. Also, I seem to need to return the value that will logically pre-populate my selectbox field (the id value) otherwise it does not pre-populate. THis doesn't make sense to me at all. Is this a secondary purpose of the value returned from this method?! Basically, if I don't have wakeupValue() or sleepValue() methods and my sanitizeValue() method just has a single line that returns $value, then my selectbox works properly in terms of saving a value, loading a value (pre-populate the field) but I then as soon as I try to add any wake or sleep functions to get my entoire record to be loaded into the page data, it all falls apart. I basically have trouble, at this moment, believing that it's only purpose is to sanitise data goign into a page object, becasue it clearly has impact on how my selectbox is rendered. If I am loading an entire record with my wakeupValue() method (whcih I blieve is the correct place for that functionality) it then seems that I need to do some sort of extra work in sanitizeValue() to make the selectbox work properly which is conteray to what you're saying about them being separate and not related. The two are definitely related in some way. Either that, or I am misunderstanding the whole process of designing a selectbox Fieldtype. It's very frustrating that I can save a simple integer reference to a DB record, but not then be able to grab that data easily. In theory I could grab it in the template using the simple ID passed through, but this seems a bit clunky to me.
  21. Thanks Ryan. I've just figured out that sanitizeValue() has to return the correct value that will make sense in the context of the rendered field in the page edit AFTER the wakeupValue() method has been executed. I think!! Correct me if I'm wrong. So in my case, because wakeupValue() is loading an entire record and turning into an associative aray, for the InputfieldSelect to correctly pre-populate the value when it loads a page for editing, my sanitizeValue() appeas to need to return the correct array element from the wakeupValue() result. I hope all this is useful to other developers!! I'm enjoying the learning process and hopefully this can all feed back into the documentation in the long run. It's a good CMS and even with the few issues I've run into so far the module/api/hook system is far superior to many other CMS'. It just takes a bit of experimentation it seems. Are you planning any proper tutorial materials? I think a step-by-step of some common tasks or even more advanced module development would be useful and encourage more people to get on board.
  22. I've just written a little fieldtype that fetches some data from a 3rd party DB and then returns a populated InputfieldSelect object. What I can't work out is that I want the current selected value to be pre-selected in the page when it is re-edited. Also, I want to automatically pull the entire related record to stick i nthe page data for templating, whereas the only bit that needs to be stored is the ID of the related record. At the moment I seem to have intermittent behaviour that sometimes saves the ID int othe field table and sometimes doesn't. Is it correct that the place I want to do the extra work (grab entire record based on saved ID) is in wakeupValue()? And in this instance, when the field is onl ysaving the ID from the selelct box as usual, can I leave sleepValue() alone? That is to say, not override it?
  23. Thanks Pete. I've managed to create a Database object and make SQL calls to a separate DB, but the thing is that I'd like to be able to use the DatabaseQuerySelect class, and other API classes, but they seem to be hardcoded to use $fuel['db'] and I can't see how I can override that. Also, at some point in the execution pipeline of using DatabaseQuerySelect there are module-related DB queries which obviously won't work if I've flipped the standard $fuel['db'] to be pointing to a separate DB. I'm not sure why these calsl to fetch module-related information are necessary but if they are then it may make it difficult to do anything with 3rd part DBs with the PW DB API.
×
×
  • Create New...