Jump to content


Photo
- - - - -

Suggestion - Calendar hook


  • Please log in to reply
16 replies to this topic

#1 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 10 December 2011 - 02:32 AM

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

#2 Freeborne

Freeborne

    Advanced Member

  • +Clients
  • 417 posts

Posted 14 December 2011 - 01:05 AM

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.

#3 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 04 January 2012 - 07:28 AM

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?

#4 Freeborne

Freeborne

    Advanced Member

  • +Clients
  • 417 posts

Posted 04 January 2012 - 07:53 PM

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

    <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>

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 :(
  • svit likes this

#5 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 05 January 2012 - 01:10 AM

Thank you, the code looks like this

<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>

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

#6 Marcher Technologies

Marcher Technologies

    $life=FALSE;$code=TRUE;$time--;

  • +Clients
  • 11,761 posts

Posted 05 January 2012 - 01:14 AM

Thank you, the code looks like this

<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>

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

maybe? not solid on that at all tbh.

#7 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 08 January 2012 - 12:44 PM

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

#8 Marcher Technologies

Marcher Technologies

    $life=FALSE;$code=TRUE;$time--;

  • +Clients
  • 11,761 posts

Posted 08 January 2012 - 02:59 PM

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>


#9 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 08 January 2012 - 03:15 PM

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..

#10 Marcher Technologies

Marcher Technologies

    $life=FALSE;$code=TRUE;$time--;

  • +Clients
  • 11,761 posts

Posted 08 January 2012 - 03:31 PM

\admin\applications_addon\ips\calendar\sources\hooks.php
line 337~
find:
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++;
  }
  }
tested and working.... the $e => $event wasnt flying, very likely because $e(array key) is either the cal_id or event_id.
  • svit likes this

#11 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 09 January 2012 - 01:22 AM

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

#12 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 13 April 2012 - 12:54 AM

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.

#13 Marcher Technologies

Marcher Technologies

    $life=FALSE;$code=TRUE;$time--;

  • +Clients
  • 11,761 posts

Posted 13 April 2012 - 02:53 AM

Find in {skin}->Calendar->boardIndexCalEvents:
<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>
?? stab in the dark it works locally.... course Im still not quite at all sure what triggers the else here in this template.
  • svit likes this

#14 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 13 April 2012 - 06:49 AM

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

#15 ThomasS

ThomasS

    IPB Full Member

  • +Clients
  • 160 posts

Posted 13 April 2012 - 07:03 AM

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?

#16 svit

svit

    Advanced Member

  • Members
  • PipPipPipPip
  • 383 posts

Posted 13 April 2012 - 07:20 AM

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.

#17 ThomasS

ThomasS

    IPB Full Member

  • +Clients
  • 160 posts

Posted 13 April 2012 - 07:32 AM

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)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users