ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to display file names without path using Matrix?

June 11, 2012 6:50am

Subscribe [1]
  • #1 / Jun 11, 2012 6:50am

    Steve Fairhurst

    168 posts

    Anyone know how to display just a file name without a path using Matrix?

  • #2 / Jun 11, 2012 9:24am

    Rob Allen

    3114 posts

    If you’re using a recent version of EE you should be able to do this with File field tag variables:

    {matrix_field_name}
    {file_name}
    {/matrix_field_name}

    .. should output just the file name, eg photo.jpg

    See the docs - http://ellislab.com/expressionengine/user-guide/modules/channel/custom_fields.html#file-field

  • #3 / Jun 11, 2012 11:54am

    Steve Fairhurst

    168 posts

    nope tried that just get (file_name} or {filename} displayed not the actual file name i.e. photo.jpg

    any other suggestions?

  • #4 / Jun 11, 2012 12:07pm

    Rob Allen

    3114 posts

    What do you get if you just output the Matrix fieldname? - do you see the full URl to the file?

  • #5 / Jun 11, 2012 12:10pm

    Rob Allen

    3114 posts

    Also what version of EE are you using?

  • #6 / Jun 11, 2012 12:23pm

    Steve Fairhurst

    168 posts

    Yeah I get the full URL to the image and using version 2.4

  • #7 / Jun 11, 2012 12:30pm

    Rob Allen

    3114 posts

    Hmm thats an odd one, it usually just works 😊

    Ok just as a text try using the example from the Docs to see if we can get something from the file field:”

    {matrix_field_name}
            This file is a {extension} and was uploaded on {upload_date format="%Y %m %d"}
            <a href="http://{url}">View it now</a>
    {/matrix_field_name}

    Does that output correctly?

  • #8 / Jun 11, 2012 3:07pm

    Steve Fairhurst

    168 posts

    Just upgraded to version 2.5.2 added the code as requested and i get the following:

    This file is a {extension} and was uploaded on {upload_date format="%Y %m %d"} View it now

  • #9 / Jun 11, 2012 4:14pm

    Rob Allen

    3114 posts

    Can you try the same code but on a normal File field? Also worth checking if you have the File module actually installed.

  • #10 / Jun 11, 2012 5:18pm

    Steve Fairhurst

    168 posts

    The file module is installed, I tried the code with the file entries tag and got the the upload date but still {extension}

    Here is my code:

    {exp:channel:entries channel="gallery" limit="1" disable="categories|member_data|pagination"}
       <div class="page-heading">
        <h1>{page_heading}</h1>
        <div class="slide-block">
         <div class="content">
          {page_description}
         </div>
         <a href="#class=info-link"><span>Show info</span><em>Hide info</em></a>
        </div>
       </div>
       <section class="visual">
        <span class="btn-click">CLICK TO VIEW LARGER IMAGE</span>
        <ul class="visual-list">
        {gallery_image} 
         <li>
          <a href="http://{path=image-archive/detail/{url_title}/{row_id}}">_       <figure>_        <span class="photo">_         {photo}_        </span>_       _        <figcaption>{file_name}</figcaption>_       </figure>_      </a>
         </li>
        {/gallery_image}

    Still the file name eludes me.

  • #11 / Jun 19, 2012 12:35pm

    Steve Fairhurst

    168 posts

    Sorted please close.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases