Jump to content

alan

Members
  • Posts

    854
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by alan

  1. My understanding is you need PHP (of course) and it can be run as/via CGI but this is not good (slow and other issues I think) or PHP can be run as FastCGI module which is AOK or as an Apache module, also AOK. So I think you are correct. I am not an expert at PHP/Apache so apologies if I am in error here.
  2. alan

    DRY URLs

    SiNNuT Ryan's suggestion does work, I have it running. The only question I have with it and I am not sure it is an issue or if it is if I care, is SEO, whether Google bot reading the 'wrong' (an internal) link rather than an external one with the chosen link test will affect anything. It's an outgoing link not an incoming one so that's good at least (less important I think). I won't. Not especially. It's more a case of wanting to know that no matter how large a site gets as/when I notice a URL ref needs changing I can change it once and all places where I used it as a link to go to an external place will automatically be corrected.
  3. alan

    DRY URLs

    Brilliant! Of course so simple that simple-me missed it! Thanks Ryan, this is exactly what I need, I got part-way there with realizing I'd want to store my links as pages but I didn't think deeper. Thanks!
  4. alan

    DRY URLs

    OK, having read up those links this DRYness looks exciting, but I don't think it will address my (this) scenario, I should have made it clearer I was thinking of links to external sites: see updateBut v.interested by this 2.3 feature for it's own sake, thanks for pointing it out. UPDATE: Actually that quoted example is bad and not clear. Sorry. I'm looking for a way to centrally store refs to external sites and then use them in textareas as elegantly as possible and as/when an external link moves I change my central reference to it and all uses of it in the site use the new edited version henceforth.
  5. alan

    DRY URLs

    @SiNNuT Thanks for the links I hadn't found those, off to go read, but not before I smile a lot at your delightful pun @Soma Thanks for the link, off to go read...
  6. alan

    DRY URLs

    Hi PWers, Have you any good ideas about how a DRY (don't repeat yourself) store of URLs could be built for subsequent use within copy? The aim being that should a URL need to be changed it could be edited in the one DRY-location and all instances of it would therefore remain correct. My idea so far is to have a utility section (not for display) such as /utils/drys/ with a URL per page /utils/drys/my-first-dry-link /utils/drys/another-dry-link each URL-page would use a template with two fields, the Title for the default copy the link would use and another field to hold the URL. Then to use the link when editing content in TinyMCE one would need to switch to HTML view and insert some PHP+PW code to refer to the link {is this even possible?}. In a perfect world I would love to be able to swipe text in TinyMCE and the pop-up list of link options include something like "The URL field from this [drop-down menu] page" and what was inserted was a PHP+PW snippet that ensured that in future when the source URL is edited each use of this link will use the new URL. Cheers to anyone with any comments -Alan
  7. Good points @JeffS and I agree with @arjen that it's handy to have this in place, at least I find it so and I continue to value the content of meta description based on Google, experience, etc and when their contents get updated at different times this auto bootstrap is useful for me.
  8. Er. Um. I got it by using the power of typo [embarrassed sound of shuffling feet]
  9. I've just found a variable or PW API value that seems to give me what I want, the trouble is I can't find it documented anywhere—anyone know if $childSchild is documented? UhOh: Red herring, please pretend I didn't type that...
  10. @doolak not that I'm aware of. I'm sure there is a thread here where someone is looking to customize the comments operation and Ryan/others answer the point and if I remember it (then) required a customization to the core (if I remember correctly).
  11. No! I prefer your non-numeric version I'll change my code and check it and then post back her! Thanks!
  12. This is the code I ended up using, thanks again to interrobang, diogo and Ryan: $blogposts = $pages->get( "/blog/" )->children; $comments = array(); foreach( $blogposts as $blogpost ) { foreach($blogpost->comment as $comment) { if($comment->isApproved()) { array_push($comments, array("comment"=>$comment, "post"=>$blogpost)); } } } if($comments) { $out = "<h2>Last three blog comments</h2>"; $out .= "<dl>"; arsort($comments); $num_comments = 0; foreach($comments as $comment) { $cite = htmlentities($comment["comment"]->cite); $text = htmlentities($comment["comment"]->text); $date = date("j M 'y ", $comment["comment"]->created); $comment_parent_url = $comment["post"]->url . "#Comment" . $comment["comment"]; $out .= "<dt><a href='{$comment_parent_url}'>{$date}</a></dt>"; $out .= "<dd>{$cite}</dd>"; $out .= "<dd>{$text}</dd>"; $num_comments++; if($num_comments == 3) break; } $out .= "</dl>"; echo $out; } else { echo "<p>No comments.</p>"; } Brilliant. Thanks guys! Updated 2012-06-14-1329 to use named arrays, much better, thanks to diogo for suggesting this
  13. Thanks again for trying so much to help me @interrobang, I can't seem to find the answer this way either. And thanks @diogo, I wondered about a two dimension array but I was already getting PHP-lost so I bailed on that. Your code does indeed work, thanks, and I'll edit my code to use it. Thanks everyone, I'll post back the final version. I'd love to know where/when the use of FieldtypeComments::findComments is documented for future projects though in case anyone finds this thread and knows. Cheers!
  14. Thanks again @interrobang for your patience, I should have spotted that the line order mattered, but I'm not so good at PHP But sadly I've changed the order to match your order and it still produces nothing.
  15. Thanks @interrobang. I tried it but it seems to produce no output (no errors but no output). This is what I had: foreach( $blogposts as $blogpost ) { foreach($blogpost->comment as $comment) { if($comment->isApproved()) { array_push($comments, $comment); // Build an array of comments $page = $pages->get($comment->pages_id); $comment->page = $page; // $page = wire('pages')->get($comment->pages_id); // tried with this line in and out but same result } } } PS: I'm using echo $comment->page; to see the ID of each comments page.
  16. Drat, I am managing to fail to solve this even with the help. I modified my first foreach to include the $page = wire(... line: foreach( $blogposts as $blogpost ) { foreach($blogpost->comment as $comment) { if($comment->isApproved()) { array_push($comments, $comment); // Build an array of comments $page = wire('pages')->get($comment->pages_id); } } } ...and then later to check I am seeing the ID of each comments parent page I added the $comment_parent code: foreach($comments as $comment) { $cite = htmlentities($comment->cite); $text = htmlentities($comment->text); $date = date("j M 'y ", $comment->created); $comment_parent_id = $comment->page; $out .= "<dt>{$date}</dt>"; $out .= "<dd>{$cite}</dd>"; $out .= "<dd>{$text}</dd>"; $out .= "<dd>{$comment_parent_id}</dd>"; $num_comments++; if($num_comments == 3) break; } But the ID returned is the same each time and is the ID of the page where the list is being shown—if I understood you rightly Ryan the edit $page = wire('pages')->get($comment->pages_id); in the first foreach should have stopped that—did I do something wrong? PS: If the use of FieldtypeComments::findComments is documented I'll try that also, I tried adding and using these functions but got errors and don't want to cloud this post so I'll ignore for now. Thanks in advance for any more pointers.
  17. Thanks Ryan, I was off in the kitchen making Tea and suddenly did a mental forehead-slap when I realized I probably needed to use the fn rather than my own code. Thanks also for extremely useful reminder how the API can be used, pearls of wisdom I keep pumping into pinboard.in
  18. Thanks @interrobang, I've not even seen that resource For the dev work I'm doing here I keep up-to-date with github so I'll go test. Cheers! Update: $comment->page; appears to be showing the ID of the page where the comment list is being viewed rather than the pages the comments belonged to. But thanks this looks promising.
  19. I've written the chunk of code below to retrieve then display the three most recent comments from blogpost Pages. I am worried that in places I may be failing to use the power of the PW API (overusing generic PHP instead). Do you see a 'tighter' / more powerful PW-API-way of doing this? Also I don't see how to retrieve the URL of the blogpost that a comments belongs to, in pseudo code I feel I want to do: $comment->parent()->url; Here's the code: $blogposts = $pages->get( "/blog/" )->children; $comments = array(); foreach($blogposts as $blogpost) { foreach($blogpost->comment as $comment) { if($comment->isApproved()) { array_push($comments, $comment); // Build an array of comments } } } if($comments) { $out = "<h2>Last three blog comments</h2>"; $out .= "<dl>"; arsort($comments); $num_comments = 0; foreach($comments as $comment) { $cite = htmlentities($comment->cite); $text = htmlentities($comment->text); $date = date("j M 'y ", $comment->created); $out .= "<dt>{$date}</dt>"; $out .= "<dd>{$cite}</dd>"; $out .= "<dd>{$text}</dd>"; $num_comments++; if($num_comments == 3) break; } $out .= "</dl>"; echo $out; } else { echo "<p>No comments.</p>"; } Any comments gratefully received, cheers, -Alan
  20. @tinacious [i'm not sure this explains anything you don't already know but]: I still need to export/import dbs (assuming I am developing locally then moving to a live host) it's just that when FTP up files as long as I don't include config-dev.php (I keep that local only) then the remote db credentials etc work immediately without having to go and edit a config file as the local settings are overridden by config-dev.php and the remote ones are setup in config.php.
  21. Not used any TinyMCE plugins (yet). The most exotic I've got with TinyMCE in PW is just adding sup as an extra button. I'm using Ryan's code very successfully for YT vids.
  22. Ryan, yes! Doh, I also had forgotten/missed the button 'Save + Keep Unpublished'. I'll go edit my original post. Thanks for putting me straight
  23. I had a nagging question: how do I build copy in the admin, check it in the real site but not allow people to see it until I am sure it is all correct. Of course it's simple and likely 100% of you knew this already, but just in case you are like me and didn't quite know, this is it: create a page but don't click 'Publish' on the page's Settings tab click 'Hidden' publish the page edit it as much as you like click 'Save + Keep Unpublished' log out, login, re-read your copy after a nice walk to see if you can improve it want to see your page in-situ (as it will look when it's visible)? Click 'View' and you see a private, unpublished but as-it-would-look version of the page as it is now repeat 4. and 5. as much as you like until you're ready to release your masterpiece, at which point just un-tick 'Hidden' and re-save click 'Publish'. Update: edited above as it's even easier than I realized, thanks Ryan for correcting me Happy editing.
  24. The answer to this may help others, I hope. It is not ProcessWire (I didn't think it was but I was hopeful someone else might have had some related knowledge that might have helped hence bothering you guys here). I had already spoken to the hoster in this case to work out which php.ini file was to be edited. The answer is interesting and easy: as I was running a website with FastCGI the php.ini file just above the httpdocs location was the one to edit, not the overall one often found in /etc/php.ini. All good, I edited it. But the problem remained. So a call to (mt), the hosters for this site, and they quickly found and fixed a one-time file that stops FastCGI working with files greater than 128KB. They upped the limit for this file to 1GB and so now this site and any others that use FastCGI will practically be controlled by the settings in their php.ini files. Result: all is working beautifully I hope this is helpful to someone else and thanks again PW people for this superb product. Cheers, -Alan
×
×
  • Create New...