I have a Tour node which has links to Accommodation nodes. In the template file for the Tour node, I have the following code to display the links to the Accommodation nodes:
<?php if (!empty($itinerary_node->field_details_link[0]['nid'])): ?>
<ul class="itinerary-links">
<?php foreach ($itinerary_node->field_details_link as $link): ?>
<?php $link_node = node_load($link['nid']); ?>
<li><?php print l($link_node->title, $link_node->path); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
The problem is that the links that are output are pointing to the Accommodation node on the current domain. As the Accommodation nodes aren't set to be displayed on the current domain, anonymous users get an 'access denied' error.
Even changing $link_node->path to 'node/'. $link_node->nid doesn't work.
What am I doing wrong? How do I make the links point to the Accommodation nodes source domain?
Comments
Comment #1
agentrickardYou have to use node/$nid, or the path lookup fails. Other things to test:
1) Is this list of links supposed to appear? Is it being run through db_rewrite_sql()?
2) Is Domain Strict turned on by accident?
3) Is the module installed correctly? Is settings.php loading the include?
4) Did you edit the 'Node Link Patterns' settings?
5) Are the source domains set properly for these nodes?
Comment #2
Anonymous (not verified) commentedThanks for the help agentrickard! Using 'node/$nid' was the answer.
Turns out it was a combination of caching issues and my trying to add a query string to the URL without knowing you should do it via the options array (part of the l() function).
All's working now :)