solved Timeline refers to gallery name, not item

iamtimbo
@iamtimbo
7 years ago
301 posts
Morning, all,

This is an observation rather than an issue, but the timeline refers to whole Gallery titles, e.g. '@user posted a new comment on Kent Miscellaneous'. As there could be several tens of photos in one Gallery, wouldn't it make more sense to use the item title as a reference, e.g. '@user posted a new comment on Chatham High Street circa 1910'?
IMG_4398.PNG.png
IMG_4398.PNG.png  •  209KB


updated by @iamtimbo: 11/17/17 10:56:10AM
michael
@michael
7 years ago
7,714 posts
You can adjust it so it works that way for your site. The main reason for it being as it is I would think is that its not certain that each photo will have a title.

When you create a gallery you can upload 10 images at a time. None of those images have titles at this point. To give them a title you'd need to edit the individual image in the gallery and give it a title.

Should be able to adjust it in the jrGallery -> item_action.tpl file.
iamtimbo
@iamtimbo
7 years ago
301 posts
Fantastic - I will do that. I see what you're saying, and I agree - it's six of one and half a dozen of the other, I think. I'll change it and see how it goes.
iamtimbo
@iamtimbo
7 years ago
301 posts
That sorts out the item entry, but not the comments (i.e. @User posted a comment on) as this is handled differently. I'm just figuring out at what point jrComment makes gallery_title the reference for the comment so that I can change it to gallery_item_title.
lornawebber
@lornawebber
7 years ago
334 posts
I need to look at this too. Thanks for posting.
michael
@michael
7 years ago
7,714 posts
How to figure this problem out.
* The template that controls how items are displayed in the timeline is the item_action.tpl file found in any module that writes to the timeline.

We want to change the Comment module's structure, so the template is:
jrComment/templates/item_action.tpl

Docs: "Altering a modules template"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1051/altering-a-modules-template

in that template we have a series of headers. I added some markers HEADER1 HEADER2 HEADER3 to understand which section is actually showing when looking at the timeline. (add_markers.png and results.png)

--
So you need to alter the second section of item_action.tpl to get the header out.

Currently that section looks like this:
......
{elseif isset($item.action_data.comment_item_title) && strlen($item.action_data.comment_item_title) > 0}

    <span class="action_item_desc">{jrCore_lang module="jrComment" id="12" default="Posted a new Comment on"}</span>
    {jrCore_module_url module=$item.action_data.comment_module assign="curl"}
    <span class="action_item_title"><a href="{$item.action_original_item_url}#cm{$item.action_item_id}" title="{$item.action_data.comment_item_title|strip_tags|jrCore_entity_encode}">{$item.action_data.comment_item_title|strip_tags}</a>:</span>

{else}
......

Its checking if the item -> action_data -> comment_item_title is set and if it is then show this section.

I added a {debug} to the template and refreshed.

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1477/debug

And can see that the title we are after IS there, but on a different variable. Its there on item -> action_original_data -> gallery_title_url

so if you use that and add a section before the current comment_item_title section then it will fire first.

......
{elseif isset($item.action_original_data.gallery_title_url) && strlen($item.action_original_data.gallery_title_url) > 0}

    <span class="action_item_desc">{jrCore_lang module="jrComment" id="12" default="Posted a new Comment on"}</span>
    {jrCore_module_url module=$item.action_data.comment_module assign="curl"}
    <span class="action_item_title"><a href="{$item.action_original_item_url}#cm{$item.action_item_id}" title="{$item.action_original_data.gallery_title|strip_tags|jrCore_entity_encode}">{$item.action_original_data.gallery_title|strip_tags}</a>:</span>

{elseif isset($item.action_data.comment_item_title) && strlen($item.action_data.comment_item_title) > 0}

    <span class="action_item_desc">{jrCore_lang module="jrComment" id="12" default="Posted a new Comment on"}</span>
    {jrCore_module_url module=$item.action_data.comment_module assign="curl"}
    <span class="action_item_title"><a href="{$item.action_original_item_url}#cm{$item.action_item_id}" title="{$item.action_data.comment_item_title|strip_tags|jrCore_entity_encode}">{$item.action_data.comment_item_title|strip_tags}</a>:</span>

{else}
......
results.jpg
results.jpg  •  357KB

add_markers.jpg
add_markers.jpg  •  142KB

action_data.jpg
action_data.jpg  •  383KB

action_original_data.jpg

iamtimbo
@iamtimbo
7 years ago
301 posts
Wow - thanks @michael! Just arrived at work, so I shall digest this on the way home.....
iamtimbo
@iamtimbo
7 years ago
301 posts
Thank you for the detailed explanation- it makes perfect sense. In fact, I needed to use {$item.action_orginal_data.gallery_image_title} unless of course there's a reason to use the URL parameter instead.

Need to mess about with the formatting but success is in the attached image (4402). With this info I can customise a lot more of the timeline, as I'd like to use the urlscan card formatting for all those type of entries - I've already done it for events, also attached (4401)...

That's been a real eye-opener! :)
IMG_4402.PNG.png
IMG_4402.PNG.png  •  85KB

IMG_4401.PNG.png
IMG_4401.PNG.png  •  149KB


updated by @iamtimbo: 05/08/17 11:29:31PM
michael
@michael
7 years ago
7,714 posts
:) the _url was a mistake by me. No problem though, you caught it. Well done.

Same concept for most places too so its re-usable:
* see whats there
* re-arrange to your liking.
* if somethings not there, get it there, then
* re-arrange to your liking. :)
iamtimbo
@iamtimbo
7 years ago
301 posts
OK. So, following your advice, I have successfully customised a few action templates. All good. In fact, love it.

My next task is to have a forum post's item_action template list the profile name and category in which a forum topic was started. Simple - except that using debug, only the forum_profile_id - a number - pulls through to the item_action.tpl, not its name.
Looking into this, I taught myself a bit about the {assign} function, thinking that I need to define a new var for the template (your 'get it there' above) - but all the values are assigned in the form process, and you can't assign variables on a form (can you?)

So my question is, can a function be used within a template to translate one variable into another? Or would it be useful to bring the profile_name in with the other forum post variables as a matter of course?
updated by @iamtimbo: 07/27/17 03:34:44PM
michael
@michael
7 years ago
7,714 posts
Yeah forums can be a bit fiddley because of the all the info. Important things about forum posts is they will all have a 'forum_group_id' on every post which will be the ID of the initial post in the thread which will contain the title of the discussion.

So as usual...... there are a number of ways to do it. The first 2 that jump into my head are:

#1 use a {jrCore_list module="jrForum" search1=""}
(change of mind)#1 use
{jrCore_db_get_item module="jrForum" item_id=$item.forum_group_id assign="info"}
That should bring in the forum post for the first item in the forum, then you can use its title from the $info variable, so
{$info.forum_title}

That would be one way to do it,
#2) another would be to define your own smarty function:

Docs: "Defining your own SMARTY function"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1569/defining-your-own-smarty-function

so you pass in the forum_group_id and get back the same info. Its basically the same as what is happening above, but doing it this way makes more sense when there are a ton more steps that need doing. In this case probably #1 is easiest as it doesnt require an extra module to be built.
iamtimbo
@iamtimbo
7 years ago
301 posts
My mind was wandering down the list route, too, but backtracked as well!

Thank you for that - that looks like a useful and powerful tool, too, so I shall have the obligatory poke about!
iamtimbo
@iamtimbo
7 years ago
301 posts
Poking about won't start until later on, but actually, looking at the datastore, the profile name of the forum containing the post (rather than the title) isn't stored (which is what I'm after), so I'm not sure (yet) that this will work...but like I said I haven't started poking about yet!
iamtimbo
@iamtimbo
7 years ago
301 posts
Ok...as I suspected, the forum host profile's name isn't pulled over - but I had sort of success using jrCore_list and assign. Dozily, I hadn't clocked that it pulls it through the whole item_list.tpl , but that inadvertently gave me a bonus feature of an unexpected Google map showing the profile location!

That said, I'm still going to try and bring over just the raw text string without a template coming too, as a boatload of a Google maps, however pretty, is going to slow down the load time.....
michael
@michael
7 years ago
7,714 posts
I didn't reply yesterday because I figured you'd get it, this sentence was important "....... Important things about forum posts is they will all have a 'forum_group_id' on every post which will be the ID of the initial post in the thread which will contain the title of the discussion........"

That's the key to getting the forum title and category. Pass that in to the {jrCore_db_get_item..... and you should get back an array with the info wanted. You can do the same thing to get any info you want.

Whats your code now? and whats the goal you're not able to reach?