Generating URL in a dynamic list

Hi everyone,

I have a loop which is displaying ticket_activity for a logged in user if they haven’t been read, this all works fine and display a list.

Now what I need to do is add a link to the main ticket, the ticket_activity is linked to a ticket.via the ticker ID/Post ID

When I use <a href="{Field url}"> the link is created for the ticket_activity post.

<Set message_owner><User email /></Set>
    <If loop exists type="wcrm_ticket_activity" custom_field=wcrm_ticket_category custom_field_value=chat custom_field_2=wcrm_ticket_activity_message_owner custom_field_value_2="{Get message_owner}" custom_field_3=wcrm_ticket_activity_message_read custom_field_value_3="no" orderby=date order=desc>
      <Loop>        
        <div class="updatedActivityItem">
          <div class="staffChatList">
            Message From:<Field wcrm_ticket_activity_message_from /><br />
            <Field content /><br />
            Relating to <a href="{Field url}">ticket</a>
          </div>
        </div>
      </Loop>

I was thinking to set a variable like below and loop through it by checking the Post ID in wcrm_tickets against wcrm_tickets_activity_ticketid the display URL based on this but I’m not to sure the best way to work this if statement or if there is a quicker way.

I hope this makes sense, long day and eyes are getting blurry.

Thanks

Tom

You’re on the right track :+1:

To get the URL field of a post, you need to loop through it, but you probably wouldn’t need to set a variable. Try something like this:

<Loop type=wcrm_tickets id="{Field wcrm_tickets_activity_ticketid}">
  Relating to <a href="{Field url}">ticket</a>
</Loop>

If you’re not sure how that works, you can give this blog post a read.

One other tip: I don’t think there’s any benefit to setting up a message_owner variable since it looks like you’re only referring to it once anyway. You could put the User tag directly in your attribute like this: custom_field_value_2="{User email}". Not a big deal, just thought I’d mention it :slight_smile:

2 Likes

Thanks again Ben,

PS great blog post regarding Loops, that has definitely helped with my understanding of Loops. Thanks for the tip as well, I started using variables because I tried adding one to a URL before which didn’t work with the < Field > tag but variable did but I will reduce my usage of them. Coming from a PHP background it’s quite difficult to stop :laughing:

Thanks,

Tom

1 Like