Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • Add-ons
  • Manager, Parser & the Core
  • PHx
  •  
  • <
  • 1
  • 2
  • 3
  • 4
  • 5
  • >
  • phx to trim path from filename?#

  • 27330
    854

    sinbad Reply #1, 2 years, 8 months ago

    Reply
    • Link to this post#1
    I want to tidy the path from the results of using @DIRECTORY binding. anyone have something like this handy maybe?


  • 20413
    2,474
    My playground: http://4up2date.info | Twitter: @mrhaw

    mrhaw Reply #2, 2 years, 8 months ago

    Reply
    • Link to this post#2
    For the front-end? http://modxcms.com/forums/index.php/topic,37657.msg227336.html#msg227336


  • 27330
    854

    sinbad Reply #3, 2 years, 8 months ago

    Reply
    • Link to this post#3
    thank man. yes for the frontend.
    problem with yours is that it trims the X chars and I have different directory so it bounds to break at some point.
    I was thinking on some preg replace or basename will work better. but can't cook it.

    something like this:
    $url = "http://www.domain.com/path/to/file/filename.php";
    $filename = basename($url);
    echo $filename; //filename.php


  • 20413
    2,474
    My playground: http://4up2date.info | Twitter: @mrhaw

    mrhaw Reply #4, 2 years, 8 months ago

    Reply
    • Link to this post#4
    Well - http://www.noupe.com/php/php-regular-expressions.html


  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #5, 2 years, 8 months ago

    Reply
    • Link to this post#5
    Can you give some examples of what you want and what you get?



  • 27330
    854

    sinbad Reply #6, 2 years, 8 months ago

    Reply
    • Link to this post#6
    I'm trying to setup a files list for clients to download. Manager user will tick the boxes of relevant filenames in backend. using @DIRECTORY and delimited list let's me *almost* get it but the files appears with full path and extra / in the path.

    When I try @DIRECTORY with the hyperlink widget it comes out clickable and valid but I have to set the display name, and that part I want to be the file name. If I use [*product_files*] I get PHx memory error.

    will take any ideas that you have on that.



  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #7, 2 years, 8 months ago

    Reply
    • Link to this post#7
    Ah, I thought you were in the front end. Another case where @SNIPPET would come in handy.

    You could do it with a monster @EVAL using readdir(). You could create the code in a snippet in the front end to test it before pasting it into the TV.
    Can you give an example of what the Input Options string would look like?

    BTW, there is a System Event called OnTVFormPrerender so you might be able to do what you want with a plugin.


  • 7923
    4,183


    "He can have a lollipop any time he wants to. That's what it means to be a programmer."

    doze Reply #8, 2 years, 8 months ago

    Reply
    • Link to this post#8
    Here's a phx modifier that returns file name from path.
    <?php
    $path = pathinfo($output);
    return $path['basename'];
    ?>

    See pathinfo in php docs.


  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #9, 2 years, 8 months ago

    Reply
    • Link to this post#9
    Quote from: doze at Aug 31, 2009, 01:58 AM
    Here's a phx modifier that returns file name from path.
    <?php
    $path = pathinfo($output);
    return $path['basename'];
    ?>

    See pathinfo in php docs.
    Very nice. I was looking for pathinfo() but couldn't remember what it was called in PHP.


  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #10, 2 years, 8 months ago

    Reply
    • Link to this post#10
    Quote from: BobRay at Aug 31, 2009, 02:03 AM
    Quote from: doze at Aug 31, 2009, 01:58 AM
    Here's a phx modifier that returns file name from path.
    <?php
    $path = pathinfo($output);
    return $path['basename'];
    ?>

    See pathinfo in php docs.
    Very nice. I was looking for pathinfo() but couldn't remember what it was called in PHP.

    BTW, I think this will do it also:
    return $basename($output);


  • <
  • 1
  • 2
  • 3
  • 4
  • 5
  • >



Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
BobRay, doze, kongondo, lossendae, mrhaw, sinbad, sottwell

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Careers at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy