Display uploaded files and download them

alt=
@dobmat
10 years ago
93 posts
Hi

I want to upload files to a module and display them in the item detail page. Fro jrGallery I can see how that can be done for images. Is there something similar for say text files.

Thanks.
updated by @dobmat: 06/25/14 01:41:52PM
michael
@michael
10 years ago
7,715 posts
Sure. You can do it for any file type that is allowed to be uploaded.

What file type is allowed to be uploaded is set by the form that includes the upload field.

How it is displayed is determined by you in the item_details.tpl page of the module.

Look at the jrFile module for examples.
alt=
@dobmat
10 years ago
93 posts
I'm trying to use jrGallery module as example to put a downlaod button on uploaded images. I have a view_jrGallery_download_image function in my jrGallery index.php and I've put the following in the gallery_update.tpl I've put the following line to get a download button. But I don't see the extra button on images in the gallery. Please give some suggestions.

Thanks.
gallery.JPG.jpg
gallery.JPG.jpg  •  41KB


updated by @dobmat: 05/15/14 07:50:34AM
michael
@michael
10 years ago
7,715 posts
use a [ code ] block to display code. [ /code ]

<input type="button" class="Gallery_update_button" .....>

The code in your image shows a link to somewhere.

What is the link that gets output in the source? Is it the location your wanting to link to? What is the location your wanting to link to?
alt=
@dobmat
10 years ago
93 posts
I want to link the download button to view_gsVenue_download_file() function in my index.php. The function is as below. But I'm getting this error "invalid location redirect token received - please try again".
jpg
 •  107KB


updated by @dobmat: 05/20/14 02:54:16AM
michael
@michael
10 years ago
7,715 posts
so the URL your wanting is:
your-site.com/venue/download_file

Just link to it.
alt=
@dobmat
10 years ago
93 posts
I tried it. But its giving "invalid location redirect token received - please try again" error. My template for putting button on each uploaded file is as below. If I try use method as described in https://www.jamroom.net/the-jamroom-network/documentation/development/1508/item-action-buttons, the button doesn't show up on each file displayed.

Thanks.
jpg
 •  94KB


updated by @dobmat: 05/21/14 01:55:12AM
michael
@michael
10 years ago
7,715 posts
I cant read the code your putting into images. use [ code ] blocks so I can check it.

If your using a normal href then there is no javascript so no redirect token is needed.
michael
@michael
10 years ago
7,715 posts
provided {$murl} is defined, that looks like it should work fine when clicking on the download icon.
alt=
@dobmat
10 years ago
93 posts
I apologise for that. Here is my code to query db for files uploaded and display them.

{jrCore_list module="gsVenue" search1="venue_title_url = `$item.venue_title_url`" search2="_profile_id = `$item._profile_id`" template='null'
order_by="venue_order numerical_asc" limit="500" assign="preview"}


{if isset($preview)}
    {foreach $preview as $it}
        <div class="item">

            <div class="container">
                <div class="row">
                    <div class="col10 last">

                        <div class="p5">
                            <h4><a href="{jrProfile_item_url module="gsVenue" profile_url=$it.profile_url item_id=$it._item_id title=$it.venue_docs_name}">
                                    {$it.venue_docs_name}<img src="../doc.png"></a></h4><br><br>
                            <span class="normal">{$item.page_body|jrCore_format_string:$item.profile_quota_id|strip_tags|truncate:180}</span>
                        </div>

                        <div id="m{$it._item_id}" class="venue_actions">
                            {jrCore_item_delete_button module="gsVenue" action="`$murl`/delete_file/id=`$it._item_id`" profile_id=$it._profile_id item_id=$it._item_id height="8" width="8"}

                            {jrCore_module_url module="gsVenue" assign="murl"}
                            <a href="{$jamroom_url}/{$murl}/download_file/id={$it._item_id}">
                                {jrCore_icon icon="download"}</a><br>
                         </div>

                    </div>
                </div>
             </div>

        </div>
    {/foreach}
{/if}
douglas
@douglas
10 years ago
2,791 posts
Your jrCore_list can't have a null template... try it like this:

{capture name="row_template" assign="venue_row"}
	{literal}
		{if isset($_items)}
			{jrCore_module_url module="gsVenue" assign="vurl"}
		  	{foreach from=$_items item="it"}
        		<div class="item">

		            <div class="container">
        		        <div class="row">
                		    <div class="col10 last">

                        		<div class="p5">
                            		<h4><a href="{jrProfile_item_url module="gsVenue" profile_url=$it.profile_url item_id=$it._item_id title=$it.venue_docs_name}">
                                    {$it.venue_docs_name}<img src="../doc.png"></a></h4><br><br>
                            		<span class="normal">{$item.page_body|jrCore_format_string:$item.profile_quota_id|strip_tags|truncate:180}</span>
		                        </div>

        		                <div id="m{$it._item_id}" class="venue_actions">
                		            {jrCore_item_delete_button module="gsVenue" action="`$murl`/delete_file/id=`$it._item_id`" profile_id=$it._profile_id item_id=$it._item_id height="8" width="8"}

                        		    {jrCore_module_url module="gsVenue" assign="murl"}
 		                            <a href="{$jamroom_url}/{$murl}/download_file/id={$it._item_id}">
	                                {jrCore_icon icon="download"}</a><br>
    		                    </div>

		                    </div>
        		        </div>
		             </div>

        		</div>
		    {/foreach}
		{/if}
	{/literal}
{/capture}

{jrCore_list module="gsVenue" search1="venue_title_url = `$item.venue_title_url`" search2="_profile_id = `$item._profile_id`" template=$venue_row
order_by="venue_order numerical_asc" limit="500"}

Hope this helps,
Douglas


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos

Tags