SimplePortal

Support => English Support => Topic started by: JulieVA on December 22, 2013, 06:48:34 PM

Title: Quick Question About Blocks
Post by: JulieVA on December 22, 2013, 06:48:34 PM
Is there anything that I can do in the Custom Display Options or the Style Options (shown below) to cause blocks to be displayed in the closed position by default so that a user would have to click the plus sign to open it if they wanted to read it?


(http://img.ourmomspot.net/images/ols221387753418/Block_is_Open_by_Default_2.png)


The "What is a Discussion Forum" Block is open by default. I would like it to display as closed so the plus sign must be clicked to open it.

(http://img.ourmomspot.net/images/tHuF1387753337/Block_is_Open_by_Default.png)

Preferred

(http://img.ourmomspot.net/images/GeOrZ1387753555/Block_is_Open_by_Default_3.png)

SMF 2.0.6 | SMF © 2013, Simple Machines
SimplePortal 2.3.5 © 2008-2012, SimplePortal

Thanks for your help!
Title: Re: Quick Question About Blocks
Post by: hcfwesker on December 22, 2013, 08:28:50 PM
[[ this is posted in the wrong section ]]

I might have something for you.  But this isn't something you can simply code in or make happen from the display Options box.  Are you ONLY wanting to do this for that one block?  "What is a Discussion Forum?"

If you can, please let me know what id the block is for that one.  Yo find the block id, goto Block List on your admin back, and hover the wrench icon in the same row as the clock name, and tell me what is says in the url for SITEURL ?action=admin;area=portalblocks;sa=edit;block_id=??   <--- the number after that is your block id

Title: Re: Quick Question About Blocks
Post by: JulieVA on December 22, 2013, 09:00:35 PM
It will be several blocks, but this one is Block ID 271 :)

I tried posting in the correct section; however, I had no "new topic" button available to me.
Title: Re: Quick Question About Blocks
Post by: hcfwesker on December 22, 2013, 09:25:01 PM
I've found a way to do this, and can show you how to do it for more blocks you wish to add later in the future.  But requires edits to 2 php files.  I want to try and test it out for myself, then i'll supply them here.  gimme about an hour or so.
Title: Re: Quick Question About Blocks
Post by: hcfwesker on December 22, 2013, 11:23:29 PM
File edits and instructions are listed below ....

Both files can be found under ..../Themes/default/


Profile.template.php

Find
Code: [Select]
</li>
</ul>
<dl>
<dd></dd>';
}

function template_notification()

Replace with
Code: [Select]
</li>';

       // Simple portal admin Options
if ($context['user']['is_admin'])
{
echo '
<li><br><b>Simple Portal Block Options</b><br>
<input type="hidden" name="default_options[sp_block_271]" value="0" />
<label for="sp_block_271"><input type="checkbox" name="default_options[sp_block_271]" id="sp_block_271" value="1"', !empty($context['member']['options']['sp_block_271']) ? ' checked="checked"' : '', ' class="input_check" /> Collapse Block 271 </label>
</li>';
}
          // End SP admin options

echo '
</ul>
<dl>
<dd></dd>';
}

function template_notification()


Settings.template.php

Find
Code: [Select]
array(
'id' => 'display_quick_mod',
'label' => $txt['display_quick_mod'],
'options' => array(
0 => $txt['display_quick_mod_none'],
1 => $txt['display_quick_mod_check'],
2 => $txt['display_quick_mod_image'],
),
'default' => true,
),

Add AFTER
Code: [Select]
array(
'id' => 'sp_block_271',
'label' => 'Shrink Block 271',
'default' => true,
),


Now, just goto Admin > Configuration > Themes & Layout > Member Options .....

Configure guest and new user options for this theme
Change current options for all members using this theme

You need to click both those links, and select "Change" for the option "Shrink Block 271", put a check mark in the box, then click save at the bottom. 

 
Title: Re: Quick Question About Blocks
Post by: oNLy1 on December 23, 2013, 12:12:20 AM
could use the spoiler tag mod and use BBCode block
(just thought I'd toss out another option)
Title: Re: Quick Question About Blocks
Post by: hcfwesker on December 23, 2013, 12:19:20 AM
That is a good idea, actually.  But, if used, then the topic itself would also be in a spoiler tag on the forum and they may want to avoid that; unless you make a clone topic in a spoiler just to be shown on the the portal.
Title: Re: Quick Question About Blocks
Post by: Chen Zhen on December 23, 2013, 12:26:47 AM
Another option is as follows:

Create a custom PHP Header Block, set it to display everywhere and check mark no title + no body.
Put the following code in the PHP block:

Code: [Select]
// enter block id's to be collapsed by default
$collapseArray = array(12,16);

echo '
<script type="text/javascript">
window.onload = function() {';

foreach ($collapseArray as $collapse)
{
if (empty($_SESSION['spcollapse' . $collapse]))
{
echo '
sp_collapseBlock("', $collapse, '");';

$_SESSION['spcollapse' . $collapse] = true;
}
}

echo '
}
</script>';

.. edit the array at the top of the block to contain the block id's you wish to have collapsed by default (12 & 16 are just examples).

Regards.
Title: Re: Quick Question About Blocks
Post by: hcfwesker on December 23, 2013, 12:58:06 AM
^ Like a Boss!
Title: Re: Quick Question About Blocks
Post by: AngelinaBelle on April 30, 2014, 08:50:31 AM
Since we have not heard back from JulieVA, I am going to mark this solved.
JulieVA, if this is not correct, please mark this "not solved" and continue asking.

Thanks!
SimplePortal 2.3.8 © 2008-2024, SimplePortal