Jump to content

Help with Fields


Svet
 Share

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...