SimplePortal

Support => English Support => Topic started by: leonylyner on March 09, 2016, 03:46:19 AM

Title: Help with Custom Display Option in Blocks
Post by: leonylyner on March 09, 2016, 03:46:19 AM
How to make use of Custom Display Option
to show a block in index.php?action=post;board=2.0
while not show in index.php?board=2.0

For example, a block that shows Tips when starting a new Topic in certain board.

Thanks!
Title: Re: Help with Custom Display Option in Blocks
Post by: andy on March 09, 2016, 04:38:21 AM
I use this - only shows when I post in the board that is not negated.

In 'Display Options' > Advanced Options> Select Actions,  Select Post.

Then in Custom Display Options:
-~topic,-~board|65,-~board|41,-~board|38,-~board|70,-~board|53,-~board|58



I did this ages ago so maybe there is a simpler way like just selecting the board, but then negating it on the board view. Then no need to negate all the others.
Title: Re: Help with Custom Display Option in Blocks
Post by: leonylyner on March 09, 2016, 04:45:05 AM
Thanks for the quick reply!

Also, is there a way to only show the block when Starting a Topic, but not show it if Replying to a Topic?
Thank you!
Title: Re: Help with Custom Display Option in Blocks
Post by: andy on March 09, 2016, 04:47:53 AM
Only the first way seems to work so you need to negate all the boards you don't want it on.
I just tried selecting the board then negating the board index view but it did not work.

Title: Re: Help with Custom Display Option in Blocks
Post by: leonylyner on March 09, 2016, 04:54:38 AM
The first way can display a block when Replying but not display it when Starting a new topic, with -~topic.
But is it possible to reverse it?
Like, display a block when starting a new topic, but not display it when Replying?

Thanks a lot!
Title: Re: Help with Custom Display Option in Blocks
Post by: andy on March 09, 2016, 04:54:49 AM
Quote
Also, is there a way to only show the block when Starting a Topic, but not show it if Replying to a Topic?

That is it - test it and you can see. It does not show on reply to topic. The reason is that topic appears in the action url so as it is negated it does not display.

Making a reply (because using -~topic it does not display):
hxxp://xxxxx.com/index.php?action=post;topic=3467.0;last_msg=15171

Making a new post (it will display):
hxxp://xxxxx.com/index.php?action=post;board=39.0

Title: Re: Help with Custom Display Option in Blocks
Post by: leonylyner on March 09, 2016, 05:01:55 AM
Oh, I get it now, thanks!
How about only show Block when Replying?
Title: Re: Help with Custom Display Option in Blocks
Post by: andy on March 09, 2016, 05:04:28 AM
This documentation page is good - it was updated to make it easier to understand.

http://simpleportal.net/index.php?action=docs;area=custom_blocks_display

Title: Re: Help with Custom Display Option in Blocks
Post by: andy on March 09, 2016, 05:06:24 AM
Quote
How about only show Block when Replying?

Try and work it out. Look at the links and see if you can use the options to make sure it only display for the reply url.
It can be done... I did not before myself.


This works in the Custom Display Options:

~last_msg

That stops it from showing when you post a new topic. Need to select the action to post and the board you want it in in the advanced options.



I thought using '-~board' would filter it out for the new topic as board occurs in the query string, but it doesn't work as it stops it in the reply as well.


Title: Doubt with custom display blocks
Post by: dsystem on March 29, 2016, 02:30:11 PM
Trying to display the block only new topic of a specific board.

but I can not.

?action=post;board=86.0

Attempts:
~action|post && ~board|86
~action|post && board|86
~action|post|board|86
~action=post|board=86

Anyone know if it's possible?
Title: Re: Doubt with custom display blocks
Post by: ♦ Ninja ZX-10RR ♦ on March 29, 2016, 02:34:03 PM
Try to display only on:
~board|86.0, ~action|post
Title: Re: Doubt with custom display blocks
Post by: dsystem on March 29, 2016, 03:19:12 PM
Try to display only on:
~board|86.0, ~action|post

Does not work.

This way the block appears in posts, board and topics

And I need it to appear only on new topic to board 86

Would have to be something like:

~board|86.0 and ~action|post
Title: Re: Help with Custom Display Option in Blocks
Post by: ♦ Ninja ZX-10RR ♦ on March 29, 2016, 05:27:46 PM
I actually merged your topic with a previous one asking just about the same thing. However, I noticed that, unless I am horribly wrong, that what you ask is not quite possible because it would show somewhere else as well, in a way or another.
Title: Re: Help with Custom Display Option in Blocks
Post by: dsystem on March 29, 2016, 08:41:36 PM
I was able to circumvent this limitation :D

Then in Custom Display Options:~board|86.0,-~topic

And ended the blockage in your PHP script

if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'post')

Code: [Select]
<?php
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'post')
{
echo 
'<div class="alert alert-info fade in"><span style="font-size: 150%; line-height: 116%;">Se apresente respondendo as seguintes perguntas:</span><br /><br />
<img alt="Atençaõ" src="http://eletronicabr.com/images/dsystem/apontador1.gif" style="float: left;" />Preencha no campo <b>Assunto: Nome / Cidade / Estado</b>

<p><br />
1. Como você conheceu o EletrônicaBR? (ex: Google ou outro site)<br />
2. Qual seu nível técnico? (Amador, Estudante, Técnico, Engenheiro, Empresário)<br />
3. Quais habilidades você pretende desenvolver?<br />
4. Conte um pouco de você. Qualquer coisa.</p>
<b>Atenção!!!</b> Mensagens que não contenham os dados solicitados acima, Dúvidas ou Pedidos de Ajuda neste tópico serão apagados.
</div>'
;
};
?>

It would be interesting to implement this feature in the next version.
Title: Re: Help with Custom Display Option in Blocks
Post by: ♦ Ninja ZX-10RR ♦ on March 29, 2016, 09:31:06 PM
Thank you for posting that! :) I'll go ahead and mark this as solved then.
Title: Re: Help with Custom Display Option in Blocks
Post by: emanuele on March 30, 2016, 05:48:06 AM
Code: [Select]
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'post' || $_REQUEST['action'] == 'post2'))^^ Covers some other cases.
Although it is shown also on editing a message.

Otherwise, if you want to be more flexible, you may be able to use some variables from SMF:
Code: [Select]
$context['is_new_topic']
$context['is_new_post']
$context['is_first_post']
TBH I'm not 100% sure they are already set when the block is prepared, but I guess it's worth a try.
SimplePortal 2.3.8 © 2008-2024, SimplePortal