1

Currently I have this setup with Views but I would like to take views out of the picture to optimize the site and fix a couple of problems that occure as a result of using Views.

What I am trying to achieve is if my nodes have content in a Body of Text called excerpt that it will show a button that links to the node's url and append the text "/excerpt" at the end of the node's url which will then display a different page with the content of excerpt on it.

I'm using Drupal 7 and am modifying a Zen subtheme.

1

The solution is<?php print drupal_get_path_alias("node/".$element['#object']->nid); ?>

This will print the URL Alias of the node that the respective field is attached to.

I found that I could get the NID of the node the element was attached to by doing<?php print_r($element['#object']);?>to find all of the available options for<?php $element['#object']?>when I found I could get the NID from that field I then put it inside of<?php drupal_get_path_alias() ?>and have it return the desired text.

It took a day to find it but it works. Hopefully someone else can benefit from this as well.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.