5

I'm a complete noob in the Craft world but love to give it a whirl for my latest project - just wondering if it can do what I want it to, and to maybe get some starting points from you guys in the know!

I'm building an Author agency website. In addition to their simple static info pages they will need to administer their 250+ clients (Authors,Public Speakers or both) and the 600+ Books by their clients. These will obviously need to be linked (through Entries as I understand it so far). i.e they want a single Author profile page (headshot, bio etc) which also displays a list that author's books, in turn linking to each book's profile page (synopsis, jacket, purchase link etc).

Now clearly I'll need either Client or Pro, as I imagine I will need to achieve this through Channels? Am I on the right track? Is there anything you think I'm missing (plugins?) Or maybe I pissing up the wrong tree?

Thanks in advance.

11

Don't be alarmed if this post gets flagged for being off-topic. Typically questions regarding whether "craft is appropriate for x" are considered too broad and opinion based. But I'll try and give you some suggestions anyway, which may give you a head start.

The short answer is yes, craft can do all those things. The only point to maybe consider is when you say "purchase", unless you are just linking to amazon or something. As I'm sure you're aware, E-commerce is not something to take lightly and I would make sure you research your options here, and have a plan. E-commerce solutions for craft are limited at the moment, but keep an eye on the plugin page.

You will likely want to have Craft Pro, so that you can have multiple user accounts.

Here is one approach to the basic CMS design, without really knowing anything about your requirements.

  • Create a single for your homepage.
  • Create a 'structure' (call it "pages" for example, or whatever you like) to contain all of your static pages and index/landing pages. This would include for example pages like "About us", "Company", "Services", "Authors" index page, "Books" index page, and anything else that you would consider as part of your main nav. 'Entries' within this structure would be defined with unique 'Entry Types' for each unique page layout that you need. Within each 'Entry Type' fields can be defined independently from other 'Entry Types'. In the 'pages/_entry.html' template you can determine which template code to display by checking the entry.type property. The advantage of using a structure here (as apposed to channels and singles) is that you can use it to generate dynamic navigation. See example below.
  • Create a channel for Authors (called 'authors' or whatever). You can also create users for this if you ever want to allow clients to log-in for whatever reason. (Note: I would use a channel regardless because it allows for multiple tabs in the edit page, and link it to users via a users field. But that's just me). Another tip: Might also check out a plugin called Introvert to display reverse related books from the books channel.
  • Create a channel for Books (called 'books' or 'products' or whatever), with a 'related users' or 'related entries' field for 'authors' (depending on how you dealt with authors above).
  • Create a category group for your books subject taxonomies (I'm just guessing at this point), but you get the idea.
  • Add salt and pepper to taste and serve.

Now for some code examples (and useful concepts regardless of your design).

In your '_layout.html' master template, to generate nav (copied from the docs):

{% set entries = craft.entries.section('pages') %}
<ul id="nav">
    {% nav entry in entries %}
        <li>
            <a href="{{ entry.url }}">{{ entry.title }}</a>
            {% ifchildren %}
                <ul>
                    {% children %}
                </ul>
            {% endifchildren %}
        </li>
    {% endnav %}
</ul>

In your 'pages/_entry.html' template, to determine the entry type and retrieve related entries:

{% switch entry.type %}
    {% case 'about' %}
        {{ entry.title }}
        ...
    {% case 'authors' %}
        {{ entry.title }}
        ...
        <ul>
            {% set authors = craft.entries.section('authors') %}
            {% for author in authors %}
                <li><a href="{{ author.url }}"></a>{{ author.firstName }} {{ author.lastName }}</li>
            {% endfor %}
        </ul> 
    {% case 'books' %}
        {# repeat code above but for books, likely with some category break-down based on the categories field #}
    {% case default %}
        {# display default template #}
{% endswitch %}

Note: You can also use 'includes' in the switch statement, for better template organization, or use this technique to eliminate the need for the 'switch' statement altogether.

In your 'authors/_entry.html' template, to get related books.

<h1>{{ entry.title }}</h1>
<p>
   <img src="{{ entry.headshot.first.url }}" />
   {{ entry.bio }}
   ...
</p>
<h2>Books</h2>
<ul>
    {% set books = craft.entries.section('books').relatedTo(entry) %}
    {% for book in books %}
        <li>
            {{ book.title }}<br>
            <img src="{{ book.coverPhoto.first.url }}" />
        </li>
    {% endfor %}
</ul>

In your 'books/_entry.html' template, to get authors from the 'authors' entries field.

<h1>{{ entry.title }}</h1>
<img src="{{ entry.coverPhoto.first.url }}" />
....
<h2>Authors</h2>
<ul>
    {% for author in entry.authors %}
        <li>{{ author.title }}</li>
    {% endfor %}
</ul>
|improve this answer|||||
  • Thank you so much Douglas, you've gone beyond the call of duty with your answer. It's really helped me a lot in my decision for using Craft. I'm beginning to dabble and so far so good! – Dr_Codswallop Feb 2 '15 at 22:22
  • Welcome to the Craft CMS Stack Exchange, @Dr_Codswallop! Please consider accepting the answer Douglas provided if you found it helpful. – Matt Stein May 10 '17 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.