Suggestion - Calendar hook

17 posts in this topic

Posted

After using the calendar hook for some time I would suggest it gives the admins option to choose how many upcoming events is to be shown in it. At present you can choose how many days it is monitoring and showing, this however has uncontrollable impact on the main page layout. If I set for example 30 days, it may be that there is no event in such case the block stays empty, but next day someone enters 15 events which completely breaks the mainpage layout, in such case I have to change the setting of the hook to say 10 days so I shrink it back. I we have set to have ti displaying 5 events I would know my main page looks as it should be.

Igor Shcherbakov likes this

Share this post


Link to post
Share on other sites

Posted

ACP > IP.Calendar > Calendar Settings
Show forthcoming calendar events = Yes
Show forthcoming events from today to [x] days ahead = 30

ACP > IP.Calendar > "Name of your calendar"
Event Limit = 2

Doesn't that limit the displayed events for each day to only 2? That's still 60 entries if there is at least 2 per day, every single day for next month.

Share this post


Link to post
Share on other sites

Posted

Thanks Freeborne, but my issue was that I needed the hook to show only say 5 events of all that users submit i don's see how this advise would make this happen?

Share this post


Link to post
Share on other sites

Posted

ACP > Look & Feel > Edit your chosen skin(s) > Templates > Calendar > boardIndexCalEvents.

Pretty sure that's the code used to display the 'hook' block on the side of your forums.

You would need to change the "foreach loop" so it only loops 5 times. I don't know PHP to do this, so a search on forums should give you an idea or expert help.

For example you could put the contents between the "foreach" tags inside an IF statement that says something like



LOL that's obviously wrong code, but hopefully gives you an idea what I mean. It should only generate a calendar event and add to the block as long as the count is 0-5. When it gets to 6 it would exit the loop. That's the theory anyway, don't know the code to make it happen or even if you need to declare the 'eventscount' variable before the condition, etc :(


    <ul class='ipsList_withminiphoto'>

	 <foreach loop="upcomingevents:$events as $event">

[b]      <if 'eventscount' < '6'>[/b]

	  <li class='clearfix'>

	   <a href='{$event['url']}' title='{$event['date']}'>{$event['title']}</a>

	   <br /> <span class='date ipsType_small desc'>{$this->lang->words['next_occurrence']} {$event['date']}</span>

	  </li>

      <'eventscount' = 'eventscounts'+'1'>

	 </foreach>

[b]      </if>[/b]

    </ul>

svit likes this

Share this post


Link to post
Share on other sites

Posted

Thank you, the code looks like this



and I wasn't able to identify where to change the count 0-5 :)

<if test="calendarEventsOuter:|:$events OR !$this->settings['autohide_calendar']">

<div class='ipsSideBlock clearfix'>

  <h3>{$this->lang->words['upcoming_events']}</h3>

  <div class='_sbcollapsable'>

   <if test="calendarEventsInner:|:is_array( $events )">

    <ul class='ipsList_withminiphoto'>

	 <foreach loop="upcomingevents:$events as $event">

	  <li class='clearfix'>

	   <a href='{$event['url']}' title='{$event['date']}'>{$event['title']}</a>

	   <br /> <span class='date ipsType_small desc'>{$this->lang->words['next_occurrence']} {$event['date']}</span>

	  </li>

	 </foreach>

    </ul>

   <else />

    <span class='desc'>{$events}</span>

   </if>

  </div>

</div>

</if>

Share this post


Link to post
Share on other sites

Posted

[quote name='svit' timestamp='1325743845' post='2217279']
Thank you, the code looks like this



and I wasn't able to identify where to change the count 0-5 :smile:

maybe? not solid on that at all tbh.

<if test="calendarEventsOuter:|:$events OR !$this->settings['autohide_calendar']">

<div class='ipsSideBlock clearfix'>

  <h3>{$this->lang->words['upcoming_events']}</h3>

  <div class='_sbcollapsable'>

   <if test="calendarEventsInner:|:is_array( $events )">

	<ul class='ipsList_withminiphoto'>

	 <foreach loop="upcomingevents:$events as $e => $event">

<if test="$e<4">

	  <li class='clearfix'>

	   <a href='{$event['url']}' title='{$event['date']}'>{$event['title']}</a>

	   <br /> <span class='date ipsType_small desc'>{$this->lang->words['next_occurrence']} {$event['date']}</span>

	  </li>

</if>

	 </foreach>

	</ul>

   <else />

	<span class='desc'>{$events}</span>

   </if>

  </div>

</div>

</if>

Share this post


Link to post
Share on other sites

Posted

Ah, marcher, that is the original hook without any change :)

Share this post


Link to post
Share on other sites

Posted

[quote name='svit' timestamp='1326044684' post='2218494']
Ah, marcher, that is the original hook without any change :smile:

then its not hitting the foreach loop there at all.... >.<


<else />

	    <span class='desc'>{$events}</span>

   </if>

Share this post


Link to post
Share on other sites

Posted

yest, that's why i have started the topics, as the hook is growing and growing, it seems i should rather contact the support team..

Share this post


Link to post
Share on other sites

Posted

adminapplications_addonipscalendarsourceshooks.php
line 337~
find:

tested and working.... the $e => $event wasnt flying, very likely because $e(array key) is either the cal_id or event_id.


foreach( $events as $event )

  {

   //-----------------------------------------

   // Recurring?

   //-----------------------------------------

   $c_time = gmstrftime( '%x', $event['_start_time'] );

   $url = $this->registry->output->buildSEOUrl( "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id={$event['event_id']}", 'public', $event['event_title_seo'], 'cal_event' );


   $show_events[] = array( 'url' => $url, 'date' => $c_time, 'title' => $event['event_title'] );

  }


change it for:


  $countme = 0;

  foreach( $events as $event )

  {

  if($countme<=4)

  {

  //-----------------------------------------

   // Recurring?

   //-----------------------------------------

   $c_time = gmstrftime( '%x', $event['_start_time'] );

   $url = $this->registry->output->buildSEOUrl( "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id={$event['event_id']}", 'public', $event['event_title_seo'], 'cal_event' );


   $show_events[] = array( 'url' => $url, 'date' => $c_time, 'title' => $event['event_title'] );

  $countme++;

  }

  }

svit likes this

Share this post


Link to post
Share on other sites

Posted

Wow, impressive :) it works, thank you so much, my pages look nice again :)

Share this post


Link to post
Share on other sites

Posted

Hi Marcher for some reason this edit doesnt work in IPB 3.3.1 and my hooks are 1km long again.. would u have any idea how to fix it? I havent received help from the helpdesk stating they would have to change to code.

Share this post


Link to post
Share on other sites

Posted

Find in {skin}->Calendar->boardIndexCalEvents:

?? stab in the dark it works locally.... course Im still not quite at all sure what triggers the else here in this template.


<foreach loop="upcomingevents:$events as $event">


Make it:


<if test="$this->_count=0"></if>

<foreach loop="upcomingevents:$events as $event">

<if test="$this->_count++"></if>

<if test="$this->_count<=5">


Find:


</foreach>


Make that:


</if>

</foreach>

svit likes this

Share this post


Link to post
Share on other sites

Posted

Oh yes! You have saved my life, I owe you.. :) Many thanks!

Share this post


Link to post
Share on other sites

Posted

[quote name='svit' timestamp='1334317741' post='2253876']
Oh yes! You have saved my life, I owe you.. :smile: Many thanks!


could you give me a link/example how this hook looks like please?

Share this post


Link to post
Share on other sites

Posted

http://www.cechoslovaci.com/ the recent event hook (topmost hook) - basically the code will cut the events list after the 5th event so it doesn't grow too big and doesn't spoil the board index page.

Share this post


Link to post
Share on other sites

Posted

ahh ok i see... so it's about the count vs. time range stuff... i thought it's also about a counter (like 5 upcoming events => "5" somewhere)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Who's Browsing   0 members

    No registered users viewing this page.