We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17460
    • 14 Posts
    Hi

    I have a php-script here that transfers contents out of my old website project into modx ressources. It executes some sql-inserts into the modx_content_table & tvvalues with data collected in my old datastructures.

    Now i got everything together except the content-alias. What is the best way to execute the Transalias plugin on my new ressources.
    Is there a way to create a modx-event which can be catched by the Transalias plugin as soon as i added the ressource into the modx-db?
    Or can the DocManager genereate aliases on all documents with empty aliases?

    Any ideas?
      • 17460
      • 14 Posts
      okay got it. I’m sure there must be an easier way.
      ...but with no help from the forum -> the following complicated solution came out:

      i wrote a php-class (ModxPlugin) that reads plugin properties out uf the db and fills it’s selected values into an array. so i can call the TransAlias plugin with the same configuration which is set in the manager.

      when the configuration is available the manual snippet call is simple. my code looks like this:
      public static function getAlias($pagename){
      	$alias = '';
      	
      	$plugin = new ModxPlugin('TransAlias');
      	$config = $plugin->getConfiguration();
      	
      	$trans = new TransAlias();
      	$trans->loadTable($config['table_name'], $config['remove_periods']);
      	$alias = $trans->stripAlias($pagename, $config['char_restrict'], $config['word_separator']);
      	
      	$alias = strtolower($alias);
      	return $alias;
      }