solved Broken URL in Forum listings on Home Page

Clay Gordon
Clay Gordon
@claygordon
9 years ago
733 posts
On my Home page, I added what I think is a nice touch in my Latest Forum Posts listings. In addition to the direct link to the post, there is a link to the category in which the post resides. I swear I tested this before moving from my old server to the new one, but the URL is now broken.

Clicking on a link takes you to ::
http://www.thechocolatelife.com//forum/where-to-buy

It should be:
http://www.thechocolatelife.com/clay/forum/where-to-buy

<strong>In: <a href="{$jamroom_url}/{$item._profile_url}/{$furl}/{$item.forum_cat_url}">{$item.forum_cat}</a></strong><br><br>

I think it should be getting my profile url (because all of the forum categories belong to my profile) in {$item._profile_url} but it's not. Unless I am misreading this code - which is entirely possible.
updated by @claygordon: 03/17/15 02:22:53PM
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
Put {debug} into the template next to your link then load up the page in your browser. The popup will contain all of the variables available in that template.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
Clay Gordon
Clay Gordon
@claygordon
9 years ago
733 posts
@ultrajam:

This is in the home page on a live site.

I appreciate that you're trying to help me figure out how to use debug.

But - it doesn't work for me. No pop-op. TheChocolateLife.com is in the exceptions list of the popup blocker.

I have a test template http://www.thechocolatelife.com/test -- I posted the source yesterday but I can repost here if you want.

I put the debug directive just before the href.

I did search the page "item._profile_url" and it's not there.

I searched the docs for it as well -- https://www.jamroom.net/docs/search?q=item._profile_url

At this point I am at a loss to understand why the call is not working.
jpg
 •  288KB


updated by @claygordon: 01/23/15 10:02:41AM
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
I've just tried your link, and when I allow the popup (in Firefox) and then refresh the popup appears.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
Clay Gordon
Clay Gordon
@claygordon
9 years ago
733 posts
It might be working for you, but it's not working for me. I just turned off the pop-up blocker.

But even if it did work, I don't see anything on the page (when I search or browse) that even remotely looks like item._profile_url and what I might replace it with.

{assign var="selected" value="home"}
{* Include Header File *}
{jrCore_include template="header.tpl"}


    {* BEGIN Container *}
    <div class="container">

        {* BEGIN TEST CODE *}
        
        <div class="row">
         
         <strong>In: {debug}<a href="{$jamroom_url}/{$item._profile_url}/{$furl}/{$item.forum_cat_url}">{$item.forum_cat}</a></strong><br><br>
        
        </div>
        {* END TEST CODE *}
	</div>
    {* END Container *}

{* Include Footer File *}
{jrCore_include template="footer.tpl"}

updated by @claygordon: 01/23/15 10:11:08AM
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
But it looks like it is just in the test.tpl as there is no $item or profile info. You'd need it in the row/item_list template used to list the forum posts.

Are you using debug within a capture block or $template block rather than an item_list template?


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
Clay Gordon
Clay Gordon
@claygordon
9 years ago
733 posts
I am using it EXACTLY as you see it above.

Here's the embedded template on the home page where I am working. This is a collaboration with Paul as I am displaying the Ning forums here, not the Group Discussions.

{if isset($_conf.nsTCLSkin1_top_discuss_active) && $_conf.nsTCLSkin1_top_discuss_active == 'on'}
{capture name="template3" assign="forum_tpl"}
{literal}
    {if isset($_items)}
        {jrCore_module_url module="jrForum" assign="furl"}
        {foreach from=$_items item="item"}
            <div class="container">
                <div class="row">
                    <div class="col2" style="padding-bottom: 12px;">
                        <a href="{$jamroom_url}/{$item.profile_url}">{jrCore_module_function function="jrImage_display" module="jrUser" type="user_image" item_id=$item._user_id size="large" crop="auto" alt=$item.user_name width=false height=false class="iloutline img_scale"}</a><br>
                    </div>
                    <div class="col10 last">
                        <div class="p5" style="padding-top: 0px;">
                            {* <h3><a href="{$jamroom_url}/{$item.forum_updated_profile_url}/{$furl}/{$item._item_id}/{$item.forum_cat_url}/{$item.forum_title_url}#last">{$item.forum_title|truncate:60}</a></h3> *}
                            <h3><a href="{$jamroom_url}/{$item.profile_url}/{$furl}/{$item._item_id}/{$item.forum_cat_url}/{$item.forum_title_url}#last">{$item.forum_title|truncate:60}</a></h3>
                            <div class="normal" style="line-height: 15px;">
                                <strong>{jrCore_lang skin=$_conf.jrCore_active_skin id="45" default="Posted"}:</strong>&nbsp;{$item.forum_updated|jrCore_date_format:"%A %B %e %Y, %l:%M %p"}<br>
                                <strong>{jrCore_lang skin=$_conf.jrCore_active_skin id="46" default="By"}:</strong>&nbsp;<a href="{$jamroom_url}/{$item.forum_updated_profile_url}">@{$item.forum_updated_user_name}</a><br>
                                <strong>In: <a href="{$jamroom_url}/{$item._profile_url}/{$furl}/{$item.forum_cat_url}">{$item.forum_cat}</a></strong><br><br>
                                {$item.forum_text|strip_tags|truncate:200:"..."}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        {/foreach}
    {else}
    <div class="center p10">
        <h3>{jrCore_lang skin=$_conf.jrCore_active_skin id="26" default="No"} {jrCore_lang skin=$_conf.jrCore_active_skin id="19" default="Discussions"}!</h3>
    </div>
    {/if}
{/literal}
{/capture}
{/if}
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
That won't work - to contain the profile url for a profile item you need to put your jrCore_list call into the template to list those items. Take a look in your index template and copy that call into your test.tpl, then the debug needs to go in the index_item_list.tpl (or whichever template is specified in your jrCOre_list call.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
Ah, you are using capture - that won't work with debug.

Either move your row code into a separate template, or take a guess as to what variable might contain the profile url - try $item.profile_url, $profile_url, $_profile_url


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
or {$item.forum_updated_profile_url}


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
Clay Gordon
Clay Gordon
@claygordon
9 years ago
733 posts
@ultrajam -

That still doesn't help me, as I am not an experienced enough programmer to figure out what that all means.

However --- I did manage to fix it. It was a typo. In copying the entire code over to this discussion I noticed that in line 10 I was using {$item.profile_url} whereas in line 19 I was using {$item._profile_url} for some reason. No exception was thrown, no error on the page, it was just not evaluating.

So, for a lark, I removed the _ after the . and it works.

I am going to have to spend a lot of time thinking about how {debug} works as I clearly don't get it. However, I do have to thank you because responding forced me to look at the code more closely to discover the source of my problem.

Thanks,
:: Clay
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
Glad you found it Clay!

{debug} doesn't work in a {capture} block with {literal}, it needs to be in a template.

Having the wrong variable name wont cause an error or exception, the variable just contains "" (nothing at all), so that's what ends up in the page.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
Clay Gordon
Clay Gordon
@claygordon
9 years ago
733 posts
As I found out about the variable name.

Can I ask you a favor?

How would you rewrite the first (shorter) bit of test code to get {debug} to work? You have the entire context in the longer block of code. If I can see what I did not get right, I will be able to make it work the next time. I can't read the actual code in the video.
updated by @claygordon: 01/23/15 10:38:09AM
SteveX
SteveX
@ultrajam
9 years ago
2,584 posts
You'd put this part into a separate template in your skin directory named (for example) index_forum_row.tpl
    {if isset($_items)}
        {jrCore_module_url module="jrForum" assign="furl"}
        {foreach from=$_items item="item"}

           {debug}

            <div class="container">
                <div class="row">
                    <div class="col2" style="padding-bottom: 12px;">
                        <a href="{$jamroom_url}/{$item.profile_url}">{jrCore_module_function function="jrImage_display" module="jrUser" type="user_image" item_id=$item._user_id size="large" crop="auto" alt=$item.user_name width=false height=false class="iloutline img_scale"}</a><br>
                    </div>
                    <div class="col10 last">
                        <div class="p5" style="padding-top: 0px;">
                            {* <h3><a href="{$jamroom_url}/{$item.forum_updated_profile_url}/{$furl}/{$item._item_id}/{$item.forum_cat_url}/{$item.forum_title_url}#last">{$item.forum_title|truncate:60}</a></h3> *}
                            <h3><a href="{$jamroom_url}/{$item.profile_url}/{$furl}/{$item._item_id}/{$item.forum_cat_url}/{$item.forum_title_url}#last">{$item.forum_title|truncate:60}</a></h3>
                            <div class="normal" style="line-height: 15px;">
                                <strong>{jrCore_lang skin=$_conf.jrCore_active_skin id="45" default="Posted"}:</strong> {$item.forum_updated|jrCore_date_format:"%A %B %e %Y, %l:%M %p"}<br>
                                <strong>{jrCore_lang skin=$_conf.jrCore_active_skin id="46" default="By"}:</strong> <a href="{$jamroom_url}/{$item.forum_updated_profile_url}">@{$item.forum_updated_user_name}</a><br>
                                <strong>In: <a href="{$jamroom_url}/{$item._profile_url}/{$furl}/{$item.forum_cat_url}">{$item.forum_cat}</a></strong><br><br>
                                {$item.forum_text|strip_tags|truncate:200:"..."}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        {/foreach}
    {else}
    <div class="center p10">
        <h3>{jrCore_lang skin=$_conf.jrCore_active_skin id="26" default="No"} {jrCore_lang skin=$_conf.jrCore_active_skin id="19" default="Discussions"}!</h3>
    </div>
    {/if}

Then your test.tpl can be changed to this:
{assign var="selected" value="home"}
{* Include Header File *}
{jrCore_include template="header.tpl"}


    {* BEGIN Container *}
    <div class="container">

        {* BEGIN TEST CODE *}
        
        <div class="row">
         
         {jrCore_list module="jrForum" order_by="_created desc" template="index_forum_row.tpl" limit="10"}
        
        </div>
        {* END TEST CODE *}
	</div>
    {* END Container *}

{* Include Footer File *}
{jrCore_include template="footer.tpl"}
The {jrCore_list call might need search parameters etc to work exactly like it does on your index page.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 01/23/15 10:45:53AM

Tags