3 Replies Latest reply on Oct 11, 2008 5:01 AM by Günter Schenk

    User Defined Directories

    921creative
      I'm sure this has been discussed before, but please point me in the right direction...

      Is it possible for a user who creates an account on my site to have his own directory that uses his username, ala myspace? For example, http://www.mysite.com/johndoe/

      That way he can share his own personal URL with his friends, who can then bypass the site's homepage.
        • 1. Re: User Defined Directories
          Günter Schenk Level 4
          Hi,

          just a pointer: here´s a code snippet I´ve been using as part of an AFTER trigger:

          mkdir ("../../user_directories/".KT_escapeForSql($tNG->getPrimaryKeyValue(),$tNG->getColumnType ($tNG->getPrimaryKey()))."", 0755);

          This example will create (aka "mkdir") a subdirectory in a specified folder (user_directories) which gets named according to the newly created Primary Key -- that´s at least my preferred way, because PK´s will never change, but user names might.

          However, as you´d like to give this directory the newly registered user name, you´ll certainly need to add some "clean up" code in order to ensure a valid directory name, and this should IMO at least include a PHP "str_replace" routine to replace possible spaces with underscores.

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: User Defined Directories
            921creative Level 1
            Günter,
            As always, I appreciate your expert support.
            This will work great EXCEPT each user directory needs to have the same set of PHP files inside (the directories won't be empty). How can I have each new directory that is created have an identical set of PHP files already residing inside upon creation?
            • 3. Re: User Defined Directories
              Günter Schenk Level 4
              -------
              How can I have each new directory that is created have an identical set of PHP files already residing inside upon creation?
              -------

              you´ll probably have to add yet another Custom AFTER Trigger which will use PHP´s "copy" function (see: http://de3.php.net/manual/en/function.copy.php) to copy the desired files from an existing server location into the newly created user directory

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver