We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43143
    • 2 Posts
    How can I change the way ModX renders a link to resources assigned to a certain template?

    I have a structure like this:


    Documentation

    Documentation category 1

    • Document1
    • Document2
    • Document3

    Document category 2

    • DocumentA
    • DocumentB


    What I want is that when a link is set on Document1 with the syntax [[~idOfDocument1]], the url generated is mysite.com/documentation/documentation-category-1/#document1

    instead of the usual mysite.com/documentation/documentation-category-1/document1.html

    I dont want my users to view my documents in a stand-alone page, I want them to view the document in its context within the category page.

    Is there a way to do that?

    This question has been answered by schouinard. See the first response.

    • I think you can do this by going to the settings tab on the documentation container and untick the container checkbox.

      Let me know if that is what you meant, good luck.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
      • discuss.answer
        • 43143
        • 2 Posts
        that did not work

        I did it with a plugin set OnDocFormSave. This is not clean (the plugin id is directly in the code). If someone has something better, please tell me.

        <?php
        // Check Event
        if ($modx->event->name == 'OnDocFormSave') {
        	$resource = $modx->getObject('modResource', $modx->event->params['id']);
        	if($resource->get('template') == 8){
        		$resource->set('uri', $modx->makeUrl($resource->get('parent')).'#'. $resource->get('alias'));
        		$resource->save();
        	}
        }