Svet Posted January 14, 2012 Share Posted January 14, 2012 Hi, I am working on my site and it seems like I can use some help! I want to add 'quotes' field that works like 'images' field. On the page you can pull an array of quotes and the admin page will have multiple input fields. Its just Textarea, but I need multiple instances of it. So from what I understand, I might need to write a new module to extend FieldtypeMulti, and then another module, like InputfieldQuote.module Does anyne know if there are tutorials covering this topic? Thank you in advance! ~Svet Link to comment Share on other sites More sharing options...
ryan Posted January 18, 2012 Share Posted January 18, 2012 Svet, apologies this message didn't show up in my new content list for some reason (I'm still learning the ropes of IP.Board). There are a couple of different approach you could take with this: 1. Let 1 textarea called 'quotes' serve the need instead. Use a regular textarea field (not TinyMCE) and enter each quote on it's own line. $quotes = implode("\n", $page->quotes); The quotes are now in an array called $quotes. You can iterate that array or pluck one randomly like you would if they had started in separate fields. 2. Or, you can create a 'quote' template and use a separate page for each quote. This is probably the approach I would take. You can select, iterate or pluck them randomly like you can with any other pages. For instance, if you wanted to output a random quote: $quote = $pages->get("parent=/tools/quotes/, sort=random"); echo $quote->body; Please let me know if I can provide additional examples. 1 Link to comment Share on other sites More sharing options...
DaveP Posted January 26, 2012 Share Posted January 26, 2012 $quotes = implode("\n", $page->quotes); Shouldn't that be explode? $quotes = explode("\n", $page->quotes); Link to comment Share on other sites More sharing options...
ryan Posted January 26, 2012 Share Posted January 26, 2012 Thanks Dave, you are right, that's a typo on my part -- it should be explode(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now