Jump to content

pokmot

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pokmot's Achievements

Jr. Member

Jr. Member (3/6)

0

Reputation

  1. Thanks apeisa, that's a very useful trick to know as well although the Admin template still outputs some content. Very useful for loading into a modal dialog box though, and I have in fact a use for it right away!
  2. Yup, Ryan, you are right - much easier than I guessed! I am used to letting the framework take control to do house cleaning etc, but with Processwire I assume from your example it's not necessary at all. I simply used exit();, and problem solved. Thanks! The more I use Processwire, the more I love it!
  3. Hi Ryan, Thanks for the example, and I see where you are coming from. However, I believe it might be "the wrong way around", I think. If I have understood your example correctly, your code can be used from a template to pull the content of an admin module? This is very useful for me too, by the way, but doesn't seem to resolve my issue. Let me be a bit more specific what I am looking for. I am writing a module which is editing a database table - this table is used to lookup information which in turn is called within the template. The module I am writing is for the administrator only, and is accessed through the "Setup" option in the admin interface. One of the things I want the module to do is to create an Excel export file by using the code at http://phpexcel.codeplex.com/. This export requires output which cannot contain any of the admin template, hence I use my "cheat" to disable the template output by tricking the admin system to believe it is an Ajax request. The alternative is create a specific page on the front end that calls my module, then outputs the content only - and I presume I can use your code to achieve this. However, I would like the module to be as easy as possible, and having extra pages on the front end to cope with this is messy, and will also be very confusing for the users of the system. I would therefore like to have a button within my custom admin module that says "Export", it then calls ___executeExport() within the module, and the Excel spreadsheet magically appears. At the moment, the only way to achieve that is the very inelegant faking of an Ajax request. So, my questions is: from within an admin module is it possible to disable the admin template without having to resort to a crude workaround? Thanks for any help, or clarification if I have misunderstood your example! Regards, Steve
  4. Hi Ryan, That would be interesting, thanks! I don't know the internals of Processwire well enough yet to figure out how to do it, but if you can either point me to a module that already does this, or paste an example in here, I would be very grateful! Regards, Steve
  5. Hi, Without going into the why's, I would like to generate output in a module used in ADMIN, WITHOUT the admin template. At the moment I am faking an Ajax request like this: $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; // Fake an Ajax request This is because the code in admin.php on line 79 checks for whether it is an Ajax request, then outputs the contents as they are if it is, or will otherwise use the admin template. I guess I could create a custom admin template which checks if a global variable is set, but it occurs to me it would be much easier if we could switch off the admin template from within the module. Is this possible, or could it be added as a configuration variable, for instance through something like: $config->disable_admin_template = true; ?
  6. It does actually work, however the code has been mangled/rewritten. The <embed> tag is completely missing although it's explicitly allowed, and the URL is inserted into the <object> tag although it shouldn't be there.
  7. Hi, Has anyone created a module for using CKEditor instead of TinyMCE?
  8. Hi guys, I'm trying to modify the configuration of TinyMCE. Note: I am NOT modifying any code in the module at this stage, I am only using the Admin interface. According to the TinyMCE website, the standard "valid elements" string is as follows: @[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big I trust the content person 100% and want them to have full flexibility in what they are doing. Specifically, I want to be able to embed Youtube videos using the old embedded style. Now, it doesn't seem to matter what I do; TinyMCE is mangling my code. I want this to be embedded (using the HTML editor in TinyMCE): <object width="420" height="315"><param name="movie" value="https://www.youtube.com/v/by8oyJztzwo?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/by8oyJztzwo?version=3&hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object> When I look at the code I get this: <object width="420" height="315" data="https://www.youtube.com/v/by8oyJztzwo?version=3&hl=en_US" type="application/x-shockwave-flash"><param name="data" value="https://www.youtube.com/v/by8oyJztzwo?version=3&hl=en_US" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="https://www.youtube.com/v/by8oyJztzwo?version=3&hl=en_US" /><param name="allowfullscreen" value="true" /></object></p> I notice the TinyMCE version is a bit out of date: 3.3.9.2. On the TinyMCE website the latest patches on the 3.3 branch is 3.3.9.4, and v3.4 7 is out too. I also tried only adding the object, param and embed codes as given here: http://processwire.com/talk/index.php?topic=486.0 - but that didn't help either. Any ideas?
  9. Hi Ryan, That's great; works perfectly both for my test code and for the real importing code I was working on. Cheers, Steve
  10. Hi Soma, Thanks for confirming there is a problem. Did you try to uncomment line 49? // If the following line is enabled then execution fails here // Reloading the page that has just been created therefore doesn't work $parent = wire('pages')->get('/holding-page'); With that the request fails with an SQL error. Adam, if you pass the name rather than the object you get an error: "Argument 1 passed to Page::__construct() must be an instance of Template, string given". Could very well be a bug in a later revision, so if you didn't use a fresh installation you might not be affected.
  11. I need to import up to 30,000 records, and add regular updates with more records, so automation is one of the first things I am looking for. I've already created a template that displays my data nicely, and I'm pretty happy so far. However, I experienced some problems when trying to automate importing of records. I have some code that will fail on first run, but succeed on the second run. It seems that when a new "page" is created, the system isn't keeping the correct information so the new record cannot be used immediately. Yesterday, my "real" code failed due to duplicate 'name' - I am using code found on the forum to append '-1', '-2' etc, but on the first run the code failed to find the records just added. On the second run it worked perfectly, every time. It therefore doesn't seem that new objects are correctly maintained in memory, and there is a mismatch between the information stored in the object and the information stored in the database. In order to get a tight use case where it fails, I produced some concept code (attached). This code will fail on the first run, but always succeeds on the second run. On the first run it fails when trying to set the template of a new page to the template that was created in the same run. On reloading the page, the template is loaded from the database and the attempt to create the page is successful. The error message is: Uncaught exception 'WireException' with message 'Invalid value sent to Page::setTemplate' in J:\wamp\www\wire\core\Page.php:593 Stack trace: #0 J:\wamp\www\wire\core\Page.php(282): Page->setTemplate('mytemplate') #1 J:\wamp\www\wire\core\Page.php(569): Page->set('template', 'mytemplate') #2 J:\wamp\www\test.php(61): Page->__set('template', 'mytemplate') #3 {main} thrown (line 593 of J:\wamp\www\wire\core\Page.php) I have commented out line 49 - if that line is enabled it always fails at that point. This line simply attempts to reload the "parent" holding page, and is identical to the code used in line 37, which either returns a Page or a NullPage object. Line 49 is only executed when a new holding page is added. Also check out the "numChildren" property of the parent page as new pages are added. This remains whatever it was on the first load of the object, although several new pages are added on each load. This makes it very difficult to automate the task (I am creating hierarchical pages, just like this example), and also means that any time an object is changed a page reload is required to ensure the correct information is available. Or am I missing something completely obvious here? Is there a 'flush' or 'reload' option somewhere? Or a mistake in my logic for creating new templates and pages? To test, have a 100% plain, freshly installed version of ProcessWire. I used a zip downloaded from Github today (no, didn't use GIT). I also made a backup of the database immediately after installing, and ensured I restored the database every time I needed to reset. Run the code 2-3 times by a browser refresh before resetting the database, to see the points mentioned above. I stored the file in the PW root directory, next to 'index.php'. The attached file only contains my "test.php", executed like this: http://localhost/test.php Thanks for any help with this. Regards, Steve test.zip
  12. Hi, Thanks very much for your help so far! Soma, will explore your module in detail and hopefully it will solve this issue for me! Regards, Steve
  13. Excellent concept, I really like it! I'll definitely get to grips with this and build a concept/prototype of this. One thing that really appeals to me is the ability to custom make an admin page that contains only what's needed for the user, and be able to use the API to easily add these as pages. Looking into the structure of the PW system further, it seems to be some really clever architecture here. As you guys have been so brilliant, allow me to ask another question. For a completely different application I am looking to create a directory portal of properties. A property owner must be able to edit their own properties, and obviously I need to store a fair bit of information about the property owner. Should then the property owner also be a 'page', albeit hidden? And I just define the fields I want? I presume then I need to create a link between the property owner and the property, to ensure only they can edit it. This again would be a new template, for instance /property/edit/property-name, where I do the security check. Am I on the right track for this? Hmmm. If so I can see quite a few uses for this system... Best regards, Steve
  14. Hi guys, Thanks for the very quick responses! Found the URL segments after writing my post, and it does seem to do the trick. One thing I really liked of PW when I was reading the API was the ease it can be called from a system shell, or integrated from another script. I have never come across a CMS quite like that. Soma, I presume the offices would need to be pages to be able to display them and link back to the skyscrapers? I should probably have mentioned that the offices must be listed on the skyscraper page rather than being separate pages. Would probably be more appropriate to call it a Recipe where the recipe description is the equivalent of the skyscraper, and the offices would be the ingredients. At the same time you need to be able to list all ingredients in the system, then have a page for each ingredient that shows all the recipes, and finally link back to what recipes they are used in. I guess the best approach would then be to use the API to get the pages of ingredients/offices containing the ID of the recipe/skyscraper, and display them in the recipe page. Sorry I have to use these kind of descriptions, I am under an NDA for this, at present, although I might be able to disclose it later. Regards, Steve
  15. Hi, I have just come across ProcessWire, and it looks very interesting for a directory application I am just starting to write. My plan was to make it in DooPHP with Smarty, but I will be investigating whether ProcessWire is a better solution. Here's how the application will work. Taking your skyscraper example, for instance a page like http://processwire.com/skyscrapers/cities/atlanta/suntrust-plaza/ Let's assume that on that particular page I ALSO need to display a list of all the offices on all the floors. I have roughly 30,000 records that are "offices" in this case, from a list of approximately 3,000 "skyscrapers". What is the best way to manage the "offices", particularly as there are changes from time to time? Would you recommend it's managed within ProcessWire, and if so, how? Or alternatively, should my template retrieve the "offices" directly from the "office" table on the mysql server? For this particular application the "offices" change on a regular basis and are updated by a master application. The purpose of the PW application is to provide a view of the data rather than managing it. The master application will also add and remove "skyscrapers" on a regular basis, so I will be writing a synchronization script to keep the database up to date. One complication here is that we need to be able to produce pages that list all "offices" of a particular type and which then links to the corresponding "skyscraper". Final question - is PW able to use URL's with wildcards, so for instance if the URL is /cities/*mycityname* a particular template is executed and the parameter *mycityname* is passed through to the template? That would be a most useful feature as it could be quite suitable for my type of application. Thanks for any feedback! Regards, Steve
×
×
  • Create New...