Jump to content

alan

Members
  • Posts

    854
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by alan

  1. Thanks Ryan, that looks very helpful for other work I am going to be doing but it it doesn't, I think, give me what Repeaters seem to be excellently suited to giving, on-the-fly user layout choices (what I am trying to do) and that is where I've been weak on this thread — failing to explain what I am trying to do So I'll explain it from the outside. I plan on the person editing copy being able to enter content into a Body field, here the short block titled Basic site profile and when they do the template will echo that output in a div with a class set to full width (actually I am using a fluid grid and the class will be grid_12). If that's all the editor wants then we're done and the footer is all that will remain. But on some pages the editor may wish to add more content presented like Aside minor one and Two (and three) as seen here. The ability for the editor to ignore this and simply not add a Repeater is dead-simple of course, and if the editor does choose to have for example three columns of content as per the linked demo, they simply add three Repeater sections, each set to 'Third' and type in their content. The PW code will mark these up in divs with class grid_4, so they create a full layout 'row'. This can of course be extended as I could use names 1ColumnsWidth, 2ColumnsWidth, etc rather than Half, Third, Quater and the same code would beautifully easily allow editors to create any combination of rows made up of any combination of column width-chunks per row. The lack of a need for different or many templates, indeed the ability to do this all within the same template, due to the presence of the brilliant Repeater panel feels superb, flexible, simple, unless I am missing something. Does that explain much better what I was trying to do and does it now seem to you also that the Repeater looks a great way to solve this? Edit: PS this shows a more sophisticated layout example.
  2. Having read this thread (thanks diogo for pointing it to me) I think my question here also addresses this issue, but differently — BUT I've not been clever enough to work out how to code it
  3. diogo thanks for the link. I should have noted that the person adding content will have had instructions to add "Segment width: half" items in pairs and "Segment width: third" items in threes, etc. Automatically, assuming I understand this correctly. The PW code I am trying to work out would, in my awful pseudo code, do this: if(Segments) { set var $number_of_segments // set var to the total number of Segments the editor added if(Segment_#1 = Half) set var $completed = 2 <div class='half'> Echo Segment_#1 >- Segment </div> <div class='half'> Echo Segment_#2 >- Segment </div> ^ | [else_if here to see if Segment_#1 = Third rather than Half, if Third then as above but different class and iterate three times; if a Quater then different class and iterate four times] | v if($completed == $number_of_segments) end else Repeat until all segments have been echoed in their respective sized divs } THANKS for the interest and I hope I've explained that well enough so I make sense :/
  4. Sorry to ask a lame question but after trying I've failed to work out the code I need to do something that I am sure must be easy to do with PW but my newb status and PHP/jQ weakness have foiled me :/ I'm using pages to make a 'select' as described here. I'm using a repeater to add two fields to the editor, one a select and the other a textarea. For my template, in my awful pseudo code I want to do this: if segment_width is set { if segment_width = half then output "grid_6" (to fill in a CSS class) if segment_width = third then output grid_4 - - - " - - - if segment_width = quarter then output grid_3 - - - " - - - output the segment field that follows on from the segment_width/is within the same repeater as the segment_width } I assume I will want a foreach or other loop as these repeater panels will be added in pairs or threes or fours and there may be more than one set, e.g.: segment_width (half) segment_width (half) segment_width (third) segment_width (third) segment_width (third) THANK YOU if you're able to point me in the right direction. Cheers, -Alan EDIT: My other post explains what I am trying to do a bit better
  5. Thanks for the explanation re 'select'. I've asked a question about the coding for selects here, in case it helps anyone else as newb as me (is there anyone as newb as me!).
  6. Oo THANKS for pointing out that it's an array DaveP, this is neat
  7. Thank you slkwrm and Dave P. If it's of interest, this is my source text: h2 What is ProcessWire? /h2 ol li a nice list /li /ol p ProcessWire gives you full control over your fields, templates and markup. It provides a powerful template system that works the way you do. Not to mention, ProcessWire's API makes working with your content easy and enjoyable. p With your code DaveP (I removed the final p wrap as the contents is going in a meta description tag) the output is What is ProcessWire?a nice list ProcessWire gives you full... which I assume is because your code searches for an explicit tag, p. I was working on stripping HTML regardless of tag but thank you for this compact approach. slkwrm with your code in place a double space I was still getting I'd not noticed is now removed, thanks, before with my code What is ProcessWire?^^a nice list^^ProcessWire gives now with your code What is ProcessWire? a nice list ProcessWire gives Delighted by the quality, speed and amount of help I've received here, thanks all.
  8. OK, so this is what I ended up with thanks to the kind helping hands of others. <meta name="description" content='<?php // Check if there is text in a field called 'summary' and if there is output it // as the author has deliberately written a meta description. Otherwise grab // the first N (e.g. 160) characters from a field called 'body', strip the HTML // tags, replace them with a space and then collapse double spaces to single // and strip leading/trailing spaces to produce a poor-mans meta description. $summary = $page->get("summary"); if($summary) echo $summary; else { $out = preg_replace('#<[^>]+>#', ' ', wordLimiter($page->get("body"), 160)); // All two space-runs to single space runs $out = preg_replace('/\s+/', ' ',$out); // No leading or trailing spaces. $out = trim( $out ); echo $out; } ?>' /> wordLimiter is as per Soma's post except that I removed 'public', I am including the function in-line at the top of this .inc file, I don't know why (due to my PHP feebleness) but with it in I got an error. Thanks again everyone for all your comments. Cheers, -Alan Edit 2012-03-13-1048 gone $out = strtr( $out, array( ' ' => ' ' ) ); replaced by $out = preg_replace('/\s+/', ' ',$out); as per #. Edit 2012-03-13-1117 OR replace all the above with this compact version
  9. Thanks everyone for your most helpful comments, now producing perfect output, I'll post back here shortly what I ended up with for my ref/to help anyone else similarly PHP disabled as I am). Cheers!, -Alan
  10. Hi netcarver, why yes, your name is familiar Nice to see some TXP people here. Thank you for the PHP loveliness, I'll go adjust! Soma, thanks for the function, re-useable and gentler ending with the elipsis is nicer and thanks for the regex too!
  11. adamkiss OK I found/remembered why I didn't use strip_tags. If the BODY that is sampled is: <h2>My hedgehogs</h2> <p>Hedgehogs are cute.</p> then strip_tags produces My hedgehogsHedgehogs are cute. I.e. it runs two words together. But thanks for the suggestions and I'm going to keep looking for that PHP tag you noted that would strip to a sentence, v. useful.
  12. adamkiss there's probably nothing wrong with strip_tags, thank you for steering a PHP 7-stone-weakling in a better direction I'll go search as suggested!
  13. Hi, I've put together a small piece of code for use in the HTML HEAD tag to automate the creation of the content for a META DESCRIPTION tag. I would be interested if anyone can see a neater way to do it or solve my regex TODO. And otherwise I'm posting just in case this is helpful for anyone else. <meta name="description" content='<?php // Check if there is text in the summary field, if so output it as the author // has deliberately written a meta description. Otherwise grab the first N // (e.g. 160) characters of the body field, strip the HTML tags, replace them // with a space and then output it as a poor-mans meta description. // // TODO this regex replaces opening and closing HTML tags and so // <h2>What are hedgehogs?</h2><p>Hedgehogs are // is cleaned up like this // _What are hedgehogs?__Hedgehogs are // when the ideal would be // What are hedgehogs?_Hedgehogs are $summary = $page->get("summary"); if($summary) echo $summary; else echo preg_replace('/<[^>]*>/', ' ', substr($page->get("body"), 0, 160)); ?>' />
  14. Thanks SiNNuT. I had totally missed that (boy am I new to this) but from chaining in jQuery I see what you mean here and it's music to my eyes, thanks for the advice.
  15. Thanks diogo for both answers, they sound simple and effective.
  16. I think I like diogo's route and have got it working after a bit of a steep learning curve (boy am I new at this). But I don't understand how to most efficiently use the results. Right now I have this in a template, just to prove it's all working (it's a bit verbose for now while I am still so unsure): $settings = $pages->get('name=site-settings'); $pref_site_name_simple = $settings->pref_site_name_simple; $pref_site_strapline = $settings->pref_site_strapline; $pref_site_name_precise = $settings->pref_site_name_precise; echo $pref_site_name_simple; echo $pref_site_strapline; echo $pref_site_name_precise; Q1. If after learning how to do this I wanted to create a new template and, say, just publish the $pref_site_name_simple, would I have to use this much code?: $settings = $pages->get('name=site-settings'); $pref_site_name_simple = $settings->pref_site_name_simple; echo $pref_site_name_simple; Q2. If I created 10 templates that will need to use this data, is there a DRY (don't repeat yourself) way to include it so that if for example I suddenly decided I wanted the third line to read: echo "This site is: "; $pref_site_name_simple; I wouldn't have to go and edit the code in 10 places? I suppose I could use .inc file but that feels very 'low tech' and feels like I am straying far from the optimum way of using PW in this example. Sorry these are such lame questions, I'm just keen to not begin on the wrong foot and use PW inefficiently. Thanks a lot for any comments, cheers, -Alan
  17. Hello everyone, Btw Having played a little with PW and read a little I am just too impressed to return to my EE training and instead have decided to just try and build the site I was due to build next with PW — thank you Ryan and others for PW. .htaccess and HTML5 Boilerplate In my build I will be attempting to knit-together the .htaccess file that comes with the HTML5 Boilerplate (H5BP) and the one that ships with PW. For many (perhaps for me when I come to do it) this will likely be very simple. Indeed I don't envisage problems but I assume I'll have a few questions. The purpose of this thread is either for others to note what they have found when doing this or if no one comments, when I succeed in merging the two by trial, error or research to list here what I found. I may be some time, but when I've done it (or read here how to do it) I'll post again and hope this may be of some help to others who may like me be a little intimidated by large .htaccess files. Cheers, -Alan
  18. Ah, THANKS wet for correcting me, I've immense respect for Dean and Textile and like using Textile very much. Thanks for correcting my assumption it was 'over entify-ing' by todays standards, I'll edit my post. Yes apeisa I totally agree that Textile and TinyMCE are so different, my bad for not making myself clearer, I was just intrigued to spot that their outputs were different.
  19. A tiny discovery I made about the source produced by Textile Vs. TinyMCE. I love Textile, a fan of Textpattern (and also Perch) I have loved using Textile over the WYSMAM (what you see makes awful markup) editors of old. But the TinyMCE used in PW looks ideal, a safe alternative to Textile (that I think I will use for customer facing editing). So I thought I'd just check the differences as far as the produced output goes: Textile <p>I call it luck. Remember, a Jedi can feel the Force flowing through him. Look, I can take you as far as Anchorhead. You can get a transport there to Mos Eisley or wherever you’re going. She must have hidden the plans in the escape pod. Send a detachment down to retrieve them, and see to it personally, Commander. There’ll be no one to stop us this time! Look, I ain’t in this for your revolution, and I’m not in it for you, Princess. I expect to be well paid. I’m in it for the money. What!?</p> TinyMCE <p>I call it luck. Remember, a Jedi can feel the Force flowing through him. Look, I can take you as far as Anchorhead. You can get a transport there to Mos Eisley or wherever you're going. She must have hidden the plans in the escape pod. Send a detachment down to retrieve them, and see to it personally, Commander. There'll be no one to stop us this time! Look, I ain't in this for your revolution, and I'm not in it for you, Princess. I expect to be well paid. I'm in it for the money. What!?</p> Conclusion I thought "Oo, Textile is better, it automatically converts required characters to their numeric entities. But then I also checked if I was behind the times as regards use of entities in HTML source. If this authoritative sounding post is anything to go by, then it looks like actually the code produced by TinyMCE is preferable [edit: Thanks to wet for pointing out Textile is only entifying where it's appropriate, so now I think the output of Textile is actually 'better' than that of TinyMCE — but it may be a subtle distinction for many people probably]. Cheers, -Alan
  20. Soma / anyone, This is off-topic really but as a newb to PW (and github), my desktop github client shows the github version is now updated, I just looked in the forum but couldn't find a post to tell me the preferred method for updating a module. Is it a case of just getting the latest version and overwriting the contents of the folder the module is in locally? Or doI need to disable the module first? Or something different? Thanks for any help, cheers, -Alan
  21. Thanks Soma! I'm going to check this out. Cheers, -Alan
×
×
  • Create New...