Using a field as a parameter for a partial?

20 views
Skip to first unread message

Steven Chanin

unread,
Oct 3, 2016, 1:33:05 PM10/3/16
to comfortable-mexican-sofa
I'm trying to use CMS for a blog on an existing site. Each blog post has an author_name. When I display the post, I'd like to also show an image of the author. I have uploaded the author images as Files.

Right now, I've got a layout that looks like:

<div class="byline">
 
<div class="author-avatar">
   
<img src="{{ cms:page:author_image_url:string }}" width="50" height="50">
 
</div>  
 
<div class="author-name">
    {{ cms:page:author_name:string }}
 
</div>
</div>

That works, but it requires users to specify the author_name and author_image_url (via copy & paste from the Files section) for each page.

What I'd really like is something where the image display is handled by something like:

<div class="author-avatar">
  {{ cms:partial:/blog/author_image:{{ cms:page:author_name:string }} }}
</div>

where the partial (author_image) gets the name of the author as a parameter which is based on the page.

I can see how to call a partial with a parameter that is always the same
cms:partial:/blog/author_image:fred

but not how to get a parameter that is page dependent sent over.

I'd also be fine with a helper, but I have the same problem of not being able to pass a dynamic parameter there too.

Is this possible?

Thanks,
Steve
Reply all
Reply to author
Forward
0 new messages