PDA

View Full Version : Forum Blocks Manager "Template to Use" field


MyLibary
11-21-2014, 04:58 AM
Hi guys,
I would like to be able to choose "Template to Use" in forum block manager in
Type "New forum posts" just like in html page.

How can i configure it so i will be able to set "Template to use" in new forum posts too?

kh99
11-21-2014, 09:46 AM
You can't select the template for a "New Posts" block. You can edit or replace the block_newposts template, but that will of course change the template for all "New Posts" blocks you have (if you have more than one).

MyLibary
11-22-2014, 09:02 AM
If i pay to someone,can he do it?
Like make that option?

ForceHSS
11-22-2014, 10:03 AM
Then you need to post in Requests for Paid Services (https://vborg.vbsupport.ru/forumdisplay.php?f=30) section if you want to pay someone

MyLibary
11-22-2014, 10:26 AM
But is that possible?

kh99
11-22-2014, 11:02 AM
It is possible. In fact, I don't think it's very difficult. In file includes/block/newposts.php, make this change, around line 81:

'datecut' => array(
'defaultvalue' => 30,
'displayorder' => 5,
'datatype' => 'integer'
),
'template' => array(
'defaultvalue' => 'block_newposts',
'displayorder' => 6,
'datatype' => 'free'
),
);

public function getData()


the part in red is added. Note that there's an added comma on the existing line before the added 'template' block.

Then around line 209:
// trim the title after fetching the urls
$postinfo[$key]['title'] = fetch_trimmed_title($post['title'], $this->config['newposts_titlemaxchars']);
}

$templater = vB_Template::create($this->config['template']);
$templater->register('blockinfo', $this->blockinfo);
$templater->register('posts', $postinfo);
return $templater->render();


The part in red is changed.

This seems to work but is missing the phrases for the labels on the config page. I'm sure that's just a matter of figuring out what the phrase name should be. Also if you have existing new posts blocks I'm not sure if they'll get the default value. They may disappear until you edit them and save them with a template name in the new field.

MyLibary
05-22-2015, 03:03 PM
That should work but in the
admincp/index.php?loc=plugin.php%3Fdo%3Dproduct

There is no option to set a template, can someone assist further?

kh99
05-22-2015, 03:25 PM
Do you mean when you want to actually set the template used by a New Forum Posts block? Then you'd go to Forums & Moderators > Forum Blocks Manager, and when you add or edit a New Forum Posts block you should see a field for template name. But as I mentioned above, you won't see it labled unless you also created the appropriate phrases (and I was too lazy to figure out what they should be named when I wrote that post).

Edit: oh, I see now that you're the one who originally asked the question, and it sounds like you understood this already. So maybe I don't understand the question.

MyLibary
05-23-2015, 09:25 AM
Yes, now i absolutely understand, but when i ask people for a quote it goes to $150 and i wonder if someone can help or should i go and pay that much?

kh99
05-23-2015, 09:29 AM
Have you tried to do the changes above? I think that's most of it, unless I didn't understand what you wanted.

MyLibary
05-23-2015, 09:48 AM
Honestly i've just saw it worked! only as you said the label is missing but who cares =)

Do you think it will cause to problems in the future with other features?

also you told me to add

'template' => array(
'defaultvalue' => 'block_newposts',
'displayorder' => 6,
'datatype' => 'free'
),

Should i remove the "," in the end?

kh99
05-23-2015, 09:59 AM
Honestly i've just saw it worked! only as you said the label is missing but who cares =)

Do you think it will cause to problems in the future with other features?

I don't see how it would.


also you told me to add

'template' => array(
'defaultvalue' => 'block_newposts',
'displayorder' => 6,
'datatype' => 'free'
),

Should i remove the "," in the end?

You don't need it. I think it can be there or not, if I'm remembering correctly.