Jump to content

teppo

PW-Moderators
  • Posts

    3,226
  • Joined

  • Last visited

  • Days Won

    109

Everything posted by teppo

  1. URL field only stores URL's, while what you're talking about here is HTML link tag and it's value. These are different things: http://www.xxyyzz.com is valid URL and thus can be stored in URL field <a href="http://www.xxyyzz.com">The text I want to show in place of the URL</a> is HTML link tag and can't be stored in URL field To achieve what you've described above I would suggest using textarea field with TinyMCE enabled (or without TinyMCE, if you prefer to write your tags as pure HTML yourself.) Other option would be storing URL in an URL field and text within text field -- ie. using two fields and outputting them like this in your template: <a href="<?php echo $page->my_url_field; ?>"><?php echo $page->my_text_field; ?></a> The best solution here, of course, depends a lot on where and how you want to use these values.
  2. @ShaltNot: semicolons are definitely comments in INI files, so altering a setting prefixed with semicolon won't affect anything. Also the setting affecting xdebug, as mentioned above, is actually xdebug.max_nesting_level. I haven't used xdebug myself so I'm not sure if it's settings are in php.ini or somewhere else -- it could have it's own config file too. One more thing to note is that you may have to restart your web server after altering PHP settings. Not 100% sure about this, but as it's a local server that probably won't do much harm either. Anyway, since your issue seems to be fixed, you may not have to worry about these anymore, just wanted to point these out in case that someone else stumbles upon this same issue.
  3. RT @shauninman: Today reminded me of this: Why are software development task estimations regularly off by a factor of 2-3? http://t.co/FCS2…

  4. RT @tkadlec: Irony: Article about importance of page load time plays an 8s interstitial ad before loading the article.

  5. Sometimes a bit of inline CSS is better than a whole lot of other hacks to get past it. One of the discussions I mentioned is this: http://processwire.com/talk/topic/2210-help-getting-a-custom-styles-php-file-working/. In a nutshell you'd have to use a .php file for your CSS and send a header telling browser that it's actually CSS file. Not very difficult, but I'd still avoid it unless it's really necessary. By the way, I replied too hastily (tried and true "reply fast, edit later" strategy) and that code there has a few issues. I've corrected them to my reply above, so you might want to check it out before trying this..
  6. You can't use PHP in CSS files by default. I'm sure you could find some discussions about that from the forums, but for now I'd suggest slightly different approach. Do something like this for the element you want to have a background-image for: <div<?php if ($pages->get("/site-settings/")->background_image) echo " style='background-image: url(" . $pages->get("/site-settings/")->background_image->url . ");'"; ?>> Rest of the settings (background-position, background-repeat, background-color etc.) you can define in your CSS file. This is probably the easiest way to get past this -- it adds a bit of inline style to your markup, but that's a very minor issue here.
  7. I haven't tried your module, but if I remember correctly it had some support for files (pdf, doc) too? If that's really the case, that alone would make it very useful.. and that's definitely what I'd recommend focusing on, as it's pretty damn important for certain sites
  8. @Peter: $field = $fields->get("account_status") returns a field object. This would in turn return field ID when converted to string. This explains the error you're getting: while $new_page->account_status returns field called "account_status" attached to that particular page, $new_page->123 (or whatever the ID of that field is) won't work (fields are called with their names, not ID values) and thus it returns an error when you try to use method "add" of this non-existent object. Am I making any sense here? Anyway, reading you post again, I must admit that I don't really get how your application works. There's just not enough data here, I'm afraid. For an example your first example gets field value from $input->post->$field_name but field name itself ($new_page->$field->...) seems to already exist at that point. This is why I'm having a bit of a hard time understanding the relation between these two code examples.
  9. Just a guess really, but have you tried $new_page->{$field->name}->add( (int) $field_value_id ); ? I'm guessing the problem might be that here your $field is an actual field (object), while what you really want is it's name.
  10. RT @ericbrynsvold: I think, at this point, I don't have the HTTP status codes memorized, solely so I can use http://t.co/zSmzQOXWED to look…

  11. .. or combine above answers to get a method that instantiates and returns your submodule when/if needed: public function submodule() { return wire('modules')->get("myModule2"); } $modules->get("myModule")->submodule()->doSomething();
  12. @kyle: well written and easy to read, thanks for sharing! Two things I'd like to point out: You might want to add some random element to your activation hashes. MD5 is easy to spot and based on that information anyone mischievous enough could easily do things like automated account creation. Not that it would matter in most cases, but if a site using this was going to be in large-scale use then I'd be a bit worried about that. You're using custom methods to sanitize URLs, usernames, hashes etc. Take a look at $sanitizer -- it provides methods for sanitizing PW usernames, text (this should be a good fit for your hash) and even URLs. No need to reinvent the wheel
  13. @Ryan: looks like I made a mistake somewhere; can't repeat my earlier results either. It definitely looks like it was CKEditor that kept stripping that class after all. This time I'm having problems with extraAllowedContent though -- it doesn't seem to affect anything no matter what I do; tried all the examples you posted and nothing works. Right after adding "allowedContent => true" class stays, but without that it disappears as soon as the field gets focus. Any idea what could be causing this? Edit: extraAllowedContent is definitely sent to CKEditor. At the moment that specific editor instance has editor.config.extraAllowedContent set to "pre[class]", but still for some reason class is removed. Strange. Edit 2: Got it.. pre[class] isn't enough, it needs to be pre[class](*). It's working now
  14. That's odd. The plugin I mentioned (pbckcode) adds classes to pre elements and those were definitely removed by HTML Purifier; right before purify() they existed, right after it they were gone (did a var_dump() before and after to make sure.) I might have to double-check this to be sure though, as I've been using customized CKEditor module since then. You're probably right. It acting overly zealous was probably just because of my admittedly uncommon use case With data-* attributes (and HTML5 elements) problem is simply that HTML Purifier only allows tags / attributes it already recognizes and since there' no HTML5 support built-in it removes all those. Whitelist instead of blacklist or some kind of heuristics probably makes sense, but it can feel rather stiff at times. Thanks, I'll try this out
  15. What you're seeing happens because your featuredImg returns "Pageimages" (multiple images) instead of one Pageimage object and that URL points to where they all reside. I'm guessing your featuredImg isn't limited to only one image via field settings? You need to do either that or specify which image you want, like this: <?php if(count($page->featuredImg)) echo "<img src='{$page->featuredImg->first()->url}'>"; ?> By the way: when dealing with multiple images / Pageimages object, you'll have to check with count() if any images actually exist. With one Pageimage you can simply check if $page->featuredImg evaluates to true (like you did in your code above.) Edit: looks like I'm too slow today..
  16. @kyle: Just tried creating pages via API in PW 2.2.9 and 2.3.1 and in both setting template, title and parent was enough, name wasn't needed.. and like @Wanze and others pointed out above that way PW automagically creates unique names. Then again, I can't really remember how this stuff worked in earlier versions, so perhaps it hasn't always been quite as simple.. Anyway, even if setting name and making it unique yourself is necessary, I'd still suggest using built-in $sanitizer (in API context wire('sanitizer')) for sanitizing your page name instead of own custom code. This way you'll get page names that are 100% compatible with PW (and with less code.)
  17. @Ryan: any chance that you could add an option for setting HTMLPurifier HTML.Allowed? Inline mode is way more usable than regular editor (partly because annoyingly tiny CKEditor windows, but for other reasons too) -- only problem there is that I can't really use it as it keeps stripping tags and attributes I really need At first I thought this should be a setting of HTMLPurifier, but perhaps a CKEditor setting makes more sense. HTMLPurifier already supports setting config options, it's just that there's no way to do it right now in CKEditor without hacking it's processInput() method. Another issue, though this may be more about HTMLPurifier than CKEditor, is that stuff like HTML5 elements and data attributes can't be allowed this easily; they would have to be added as custom attributes and elements, one by one. No wildcards supported here. I don't know if there's really a sensible way to implement a setting for these, though. (As for real world usage example, pbckcode plugin which I use both to edit code and add simple metadata (such as language) uses data-attributes. Luckily it also adds classes, which can be allowed via HTML.Allowed, so problem is mostly fixed with that.) Edit: forgot to add that in addition to HTML.Allowed, CKEditor allowedContent setting needs to be set too. Otherwise content is saved properly but parts of it might get removed when activating the editor, which isn't very nice Annoying thing is that the format for allowed content seems different in CKEditor and HTMLPurifier. I might be completely off the track here though -- while testing this I simply disabled whole CKEditor allowedContent filter by setting it to "true".
  18. Our clients have reported identical problems a few times. After clearing browser history things have returned to normal. This is probably unrelated, just wanted to point out that the issue may not be site-related at all..
  19. Possibly just a slip, but.. you didn't mention A List Apart there? Other than that, http://www.zeldman.com/, http://davidwalsh.name and http://addyosmani.com/blog/ are quite entertaining... oh, and http://blog.ponyfoo.com/ of course! Too much good stuff to keep track of nowadays but that's what Twitter is for.
  20. OK, that didn't work quite as planned -- too much content there obviously. Was it actually cut in the middle like that or did the part with that URL you're trying to output show up too? If it did, it'd be nice to see that and a few lines around it, just to make sure.. What I was looking for was what your $outBody variable exactly looks like at that point -- ie. if it has PHP code, such as <?= ...whatever... ?>, in it. In that situation simple echo wouldn't eval the code and it would print out as-is. @Soma: that shouldn't be needed. PHP echo and short echo can both handle ternary operator just fine.
  21. Short excerpt from search.php of Foundation site profile: // if the above doesn't find anything (perhaps due to MySQL minimum word // length or stopwords), switch to non-indexed phrase match if(!count($matches)) $matches = $pages->find("title|body%=$q, limit=$limit"); This is actually pretty nice idea -- use faster method first and only if it seems to fail switch to slower one. Don't know how much difference that really makes, but still. Also: there's a pager now, which is pretty obvious improvement already
  22. I may be a bit tired here, but I can't see how that was even related to what I asked above Let's try this instead: insert <?= var_dump($outBody) ?> right before your "$partial->set('text_area', $outBody)" row and paste it's result here. This should pretty much show if I was on the right track or not.
  23. This all seems a bit confusing, so I'm not really sure if I'm even on the right track here, but still: is that first piece of markup + PHP you posted actually a variable value, ie. your variable contains stuff like "<p><?= ... ?></p>" etc.? In that case the problem would be that just echoing out a string containing PHP won't (and shouldn't) evaluate that PHP as code. You'd have to use eval() for that, which on the other hand is something I'd strongly recommend against. Anyway, if that's the case I'm sure there are a ton of better options -- but before going any further I'd like to confirm if my guess was anywhere close to reality?
  24. Selector operator "~=" means that at least one of the fields you've defined (teaserBody, contentHeadline, contentBody) has to contain all specified words. Order doesn't matter, though. Are you absolutely sure that's the case? This could also have something to do with either stop words or length limitations, so you might want to test it with longer words and/or change selector from "~=" to "%=". This is a bit slower, but so far I've been using it pretty much everywhere without any severe performance issues.
×
×
  • Create New...