Hi,

Can anyone give me a hand hacking the artcile module to display a paragrah of text under the title of the page. I am using it as a rant wall for a client, and he requires submission guidlines and page description under the title.

here is alink to the page: http://wwwfrontiercoaching.com.au/?q=article

And I want to be able to add standard text and maybe a link or two under the title (Rants & Raves).

It is quite urgent,b ut I will be happy with what help I can get.

Thanks,
Nathan Wheatley

Comments

nevets’s picture

Look at the function article_view() it should produce the output for one article.

Now add code to build up the stuff before the body (say it's in $info)

Then set the $node->body = $info . $node->body.

If you need more help, let me know and I will see what I can do later tonight.

nathanwastaken’s picture

That function does not exist, as this is not a content type, but a specialised taxonomy display.

If you wouldn't mind having a look, I would much appreciate it. Thanks for your suggestion, and I am sorry it did not work.

Regards,
Nathan

Mateo’s picture

In the function "article page" insert your paragraph and links like this:

search for the line that says:
if ($recent_count > 0) {
**->>$body = "<p>ENTER YOUR TEXT HERE</p>";
**->>$body .= '<a href = "www.link.com">linkname</a>';
      	$body .= theme("box", t("Latest Articles"), node_title_list(...etcetc

The areas with the arrows are things I added. Notice that I also added a period to the last $body. you can also use the l() function for your link, but I figure that since we're already getting down and dirty we might as well do straight HTML.

If you are interested in a more managable solution (like a user-defined field that is customizable in settings) I can help you but not today. Either way, this should work for now.

Mateo

nathanwastaken’s picture

I just made the changes, but unless I have done something wrong, it has not worked.

I added the two lines of code (un-touched) to the place that I was directed (I have triple checked), uploaded it, that the previously stated link points to the NEW version, and it does not work.

I am not sure what I have done wrong.

Mateo, i would really appreciate you creating a form on the article admin page, so that the user could specify text to be added at the top of the page. I said it was urgent, but I would be happyif you could do it, so take your time.

I really appreciate your assistance.

Regards,
Nathan Wheatley

CodeMonkeyX’s picture

You probably forgot to add the period before the = sign on the last line of the example Mateo posted. If there is only an = sign, then whatever you put in $body will be erased.

Mateo’s picture

I was thinking the same thing. The period in PHP works like the "&" sign in Visual Basic.

Quick PHP lesson:
If I start with:
$test = "I like...";

and the next line is:
$test .="cheese";
the resulting $test string will be "I like...cheese." If I forget the period on the last instance the $test string will be "cheese."

Anyway, I can help you get the module working soon. What version of Drupal are you using?

Mateo

nathanwastaken’s picture

I am using the 4.6RC, but I added the persiod, and it worked.

It would be great if th user could change the text, but now that it is working, it is no urgent. (This would also probably go as a feature request for this project).

Thanks to everyone who helped out. It was MUCH appreciated.

Mateo’s picture

I'll spend some time on it by next week. Do you want just one paragraph block? How many links do you want to account for?

Mateo

Mateo’s picture

I have not tested this (I'm using 4.5.2 not 4.6) but it should work. Add the following lines of code where I tell you to add them.

In the function "article_settings" you will add the following code directly above where it says "return $output"

$output .= form_textarea(t('Article Introduction'), 'article_intro', variable_get('article_intro', ''), 70, 5, t('This text will be displayed at the top of the article main page.  It is useful for helping or instructing your users.'));

in the function "article_page" add the following code where I had you put the other code before. So directly under "if ($recent_count > 0) {" put the following code:

$body = variable_get('article_intro', '');

Do NOT for get to keep the period on the next line. The next line should start with "$body .= theme("box", ......"

From then on the paragraph can be changed by the user in the settings -> article page.

I may be wrong about how this is done, but it seems that this should work. If there are any module developers who can point out the error in my thinking, please let me know.

If you'd rather download the entire module from me instead of entering the code yourself, send me an email through Drupal. Otherwise let me know how it turns out.

Mateo

nathanwastaken’s picture

I really appreciate the time you have spent on this. I am reallt happy with the result (and it does work for me, with 4.6RC).

Thanks again,
Nathan Wheatley

hpk’s picture

Thanks

hpk a.k.a. vikram
[De-centralizing the central issues]
National Institute of Design, India