We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    HI there,

    I've been using importX to pull in a bunch of resources form a csv file.
    All good apart from the latest hiccup.
    The Alias is created from the pagetitle (as per when you create a new resource from the tree).
    But, if the page title is the same on more than one resource, it falls over.
    Instead of adding a 1 to the alias, it just stops the import.

    I know I can add another field of 'alias' in the csv file, but the problem with this is that I'm running out of names to use - is there any way for the resource to generate a random alias for each resource I import?
    To give context, it's s bunch of testimonials, where the date is the title, therefore I have a lot of testimonials which have the same date.

    Thanks
    Andy
      • 3749
      • 24,544 Posts
      This might work (untested):

      Add this between lines 61 and 62 of the core/components/importx/processors/prepare/csv.php file:

      $lines[$line]['alias'] = $lines[$line['pagetitle']] . uniqid();


      It goes just below this line:

      $lines[$line] = array_combine($headings,$curline);) 


      That should add a unique number to the end of the alias (which will still begin with the pagetitle).
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting