I got on example http://aporia.com.pl/filozofia-wstep On bottom of article, its something like "Link that"

Podlinkuj wpis:
<br />Kod html do wstawienia na stronę:
<br /><textarea style="width: 400px; height: 3em"><a href="http://aporia.com.pl<?php echo $_SERVER['REQUEST_URI']; ?>">Something</a></textarea>
<br />Kod BBCode do wstanienia na forum:
<br /><textarea style="width: 400px; height: 3em">[url=http://aporia.com.pl<?php echo $_SERVER['REQUEST_URI']; ?>]Something[/url]</textarea>

Its code for BBCode and html on site. Its great generate me suitable url. But how to make this will code will also print not anachor text "Something" but a title of article?

Comments

tatar111’s picture

Maybe that will be more simple. How to make to print (by using php or something else) somewhere in content a title of node that code is in?

Think. Filozofia i Religia. Or Filozofia i Religia.

nevets’s picture

Where are you tring to print this information from, a template file (*.tpl.php), template.php, a node body, somewhere else?

tatar111’s picture

I want to print it from title of article. How?

Think. Filozofia i Religia. Or Filozofia i Religia.

nevets’s picture

The content of a node is unaware of what node it sits in. When the node is displayed by it's self the path is of the form "node/{nid}" and one can get the information you want. Note though, the teaser view will not have this information available.

So the first part is to get the node object

<?php
if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
  $node = node_load(arg(1));
}
?>

Then in the code you can build links like this

<?php if ( $node ) print l($node->title, "node/$node->nid"); ?>

The example links the node back to it's self, you probably want a different path.

tatar111’s picture

No, its not that I need but thx. Maybe somehow to print a all h2 on site in place I want? How to do that? Or maybe get some title from database, but how?

Think. Filozofia i Religia. Or Filozofia i Religia.

nevets’s picture

Can you clearly state what you are trying to do, what it is you want to achieve. I am unclear if you are trying to change the way the page looks or add a link within content (the later is not about h2 tags).

tatar111’s picture

Tell me only how to print somewhere in article a title of it by php. I dont want to write it manual. Example:

Title of article: Drupal is great

Content: Sometext, sometext, sometext, sometext, sometext, sometext, sometext, sometext, sometext, sometext, sometext, sometext, <Title of article>, sometext, sometext, sometext. <Title of article>, sometext, sometext, sometext. <Title of article>, sometext, sometext, sometext.

How to print by using php. Because when I edit a title I want it automatical to change in content. How to do that?

Think. Filozofia i Religia. Or Filozofia i Religia.

nevets’s picture

That is what the comment http://drupal.org/node/183694#comment-281338 does but it only applies to full page views and not other cases (list and teaser views).