I'm basically trying to set up the inbox so I can have the message subject and under that a teaser view of the message body. However I can't seem to print the message body. I made a module to make use of hook_privatemsg_sql_list_alter but it doesn't seem to take. I also tried using the same method in my template.php file. Am I doing something wrong? I looked around and haven't found much documentation with examples.

Heres what's in my module file. The module name is fp_privatemsg

function fp_privatemsg_privatemsg_sql_list_alter(&$fragment, $account) {
$fragments['select'][]= "pm.body";
}

Comments

naheemsays’s picture

What is the custom module called? if it is fp_privatemsg, the function name above is correct. if it is called fp only, then try

function fp_privatemsg_sql_list_alter(&$fragment, $account) {
$fragments['select'][]= "pm.body";
}

instead.

After that, you will also need to use the theme functions to show the teaser - by default the module will NOT show extra fields.

walker2238’s picture

Wow talk about fast support...

The module is indeed fp_privatemsg

And I should also note that I tried to print is using $thread['body'] which I printed in function fp_privatemsg_list_field__participants($thread), fp being my theme.

This works fine if I hack the module but adding $fragments['select'][]= "pm.body"; into function privatemsg_sql_list(&$fragments, $account, $argument = 'list')

naheemsays’s picture

also, you are using both &$fragment and $fragments - is that the case is the code too? if so, change one to the other (I am talking about the "s" at the end)

walker2238’s picture

Um, you lost me on that one, I don't understand.

naheemsays’s picture

there is a missing "s" at the end in one of them.

walker2238’s picture

That odd... your right. It works fine after I changed fp_privatemsg_privatemsg_sql_list_alter(&$fragment, $account, $argument) to fp_privatemsg_privatemsg_sql_list_alter(&$fragments, $account, $argument)...

Maybe I don't understand how this works but when I was looking at the documentation the funtion is listed as...

function hook_privatemsg_sql_list_alter(&$fragment, $account) {
}

soure: http://blog.worldempire.ch/api/function/hook_privatemsg_sql_list_alter/1

walker2238’s picture

I understand that my issue was me not examining the code well... but whats the difference between $fragments and $fragment?

naheemsays’s picture

you can use whatever name you like as long as it is consistent throughout. if you use $fragment in the function name, you have to use $fragment throughout. If however you append the s in the function name, it should also be appended throughout.

You can even call it $random_arg all the way through - it is the positioning (and consistency) that matters.

The docs probably need to be fixed to be more consistent.

walker2238’s picture

Ok sorry I'm trying to work while doing this so I'm not processing the information. I understand that the variables have to match, just didn't understand why theres two variables that do the same thing. I do agree that the documents are well... under documented. But it's free so I can't really complain.

Thanks so much for your quick replies. I'd say lets trade brains but I already know the answer to that.

Cheers!

naheemsays’s picture

Status: Active » Fixed

:)

just didn't understand why theres two variables that do the same thing

There aren't - just the one, but the documentation seems to miss the s that breaks consistency.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.