How to use php include() or require() in a page or story content
Hi everybody!
I'm really new with drupal and I have a problem when I try to plublish a new content.
I need to create "dynamic links" for use them in stories, pages, blocks, etc. With "dynamic links" I mean anchors that I need to change sometimes in the future and I want to change them in once without edit every content where the link is published.
My first idea was to use the include() or require() function on php using the php filter but it throws and error explainig that is not possible to use these functions. There is any way of use these functions??
I want to define somewhere ( php file, txt, mysql ...) the links.Something like this:
Resource R:
link_a = http://www.linka.com
link_b = http://www.linkb.comAfter I want to put a lot of articles, stories, blocks, pages where I want to use the link a. Something like this:
inlcude (resourceR);
<a href = " $link_a " >example< / a >Imagine that the link a appear 20 times in different places of drupal and every week I need to change the value of the link, for this reason I want to have the links all together somewhere, in this way only changing the value in the resource is changed in all places.
Sorry my english is not really good I don't know if I explained my problem clearly. All your help and comments are welcome and thanks in advance :-D.

create a block
Why not create a block with the links you want and add that block on your content. Then when you want to change the link, change in once place in that block and it will get reflected everywhere.
You don't need include or require. That is the reason the blocks are meant for. You don't need to add block one by one. There are several ways to add same block on multiple pages. And blocks can have html, javascript or php code that gets included on every page that you want.
Thanks for your answer. The
Thanks for your answer. The problem is that I want to put these links in blocks like you said but also I want to mix them inside the text of the content for better visibility, I think that putting them in blocks are less visible for the user. I want to use these links for Commision Junction and every time one person click on the anchor I get money, for these reason I want to put the link as much as posible everywhere i can, and not only in blocks.
Any suggestion?
you can add blcok close to content
Several themes have region for at the top of the content and bottom of content. You can also add custom region close or a div inside the content and then assign the block to those region. One advantage of this approach is you can create several pseudo blocks (blocks with different code based on condition) so there are different commision junction links for different pages. Different links reduces ad blindness and make your site more useful if those ads are relavant.
Consider the path of your
Consider the path of your include and the current path of the page you are viewing. For nodes the path typically ends in something like node/123. As shown your path is relative which makes it relative to the current pages path. So in cases liike this the problem is the path is resolving to something like node/123/resourceR and the chances are that does not exist.
Thanks nevets. But there is
Thanks nevets. But there is no way to refer the include with the absoulte path?? I had the same problem with the images, I wanted to put a lot of images in every page but uploading directly with FTP and not using any module of drupal. The problem was the same, the relative path, finaly I added in the page.tpl.php
<base href="http://www.url.com" />and in this way i can put the images like<img src="img/image.gif">without worry about the path.There is no something similar that I can do for include any type of resource? It doesnt matter if it is a php include, javascript file, or querying the database.
Depending on how you server
Depending on how you server is configured a absolute path may work, the other choice is to make a dictory relative to your root (lets call it 'scripts' and use a relative reference liike '../../scripts/resource'.