1 of 3
1
Calendar Enhancements
Posted: 11 April 2006 09:00 AM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1506
Joined  05-15-2004

I’d like to see the following things added for use between the {entries}{/entries} tag pair in a calendar:

1) Access to fields other than title, for example for producing excerpts from posts in the title attribute of the link to said post.

2) Access to the {count} variable to indicate number of entries per day when space concerns don’t allow all of them to be shown.

3) A way of specifying how many entries to show on a day where you have more than one entry.

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

Profile
 
 
Posted: 11 April 2006 10:04 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  750
Joined  08-16-2003

For #2, here’s a quick hack. In modules/weblog/mod.weblog_calendar.php find:

$out = str_replace(LD.'day_number'.RD, $day, $out);

Immediately below that, add:

$out = (isset($data[$day])) ? str_replace(LD.'count'.RD, count($data[$day]), $out) : str_replace(LD.'count'.RD, '0', $out);

I went ahead and added that feature to Repeet for the next version.

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 12 April 2006 12:31 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  92
Joined  12-12-2002

Thanks for this hack Mr. Wilson.  Did you get #3 to work Linda?  I’m attempting to tackle a similar problem.  Right now I’m assigning an author that is omitted from the calendar entries for duplicates, but I’d rather not need to use such a cludgy method.

 Signature 

Gridwork Design * Site design for small organizations

Profile
 
 
Posted: 12 April 2006 12:36 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15867
Joined  06-03-2002

After using Mr. Wilson’s modification, you should be able to perform conditionals with the {count} variable to determine how many entries to show, no?

 Signature 
Profile
MSG
 
 
Posted: 12 April 2006 01:00 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  92
Joined  12-12-2002

Hmm.  I was able to render the count variable, but when I added a conditional it wasn’t parsed and showed up as text on my template.  I added the conditional between the {entries} tag pair, so maybe it was invalid there.  Regardless, I can’t visualize how one would limit the number of entries on a given day with a conditional.  Sorry if I’m being a blockhead…

 Signature 

Gridwork Design * Site design for small organizations

Profile
 
 
Posted: 12 April 2006 02:17 PM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1506
Joined  05-15-2004

Thank you for the hack, Mr. Wilson. smile

I can get the {count} by itself to show up fine, but when I tried to use a conditional in the link title it did not work so well. What I tried what this:

There {if count == “1”}is 1 entry{if:else}are {count} entries{/if} for this day.

This results in the entries not being displayed at all.

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

Profile
 
 
Posted: 12 April 2006 02:43 PM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15867
Joined  06-03-2002

Conditionals probably aren’t allowed there.  You could probably do it with PHP (set to output).

 Signature 
Profile
MSG
 
 
Posted: 12 April 2006 03:19 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  750
Joined  08-16-2003

Here’s another hack, this time for #1. In modules/weblog/mod.weblog_calendar.php we need to make changes in a couple locations. First find:

$data[$d][] = array(
  
$TYPE->parse_type($row['title'], array('text_format' => 'lite', 'html_format' => 'none', 'auto_links' => 'n', 'allow_img_url' => 'no')),
  
$row['url_title'],
  
$entry_date,
  
$permalink,
  
$title_permalink,
  
$author,
  
$profile_path,
  
$id_path,
  
$base_fields,
  
$comment_tb_total,
  
$day_path
);

We’re going to add an array called $row to the bottom, like so:

$data[$d][] = array(
  ...(
blah blah blah)...
  
$day_path,
  
$row
);

Don’t forget the comma after $day_path!

Next move way down toward the bottom, to the var_replace function. Look for:

$str = str_replace(
  array(
LD.'title'.RD,
    
LD.'url_title'.RD,
    
LD.'author'.RD,
    
LD.'comment_tb_total'.RD,
    
LD.'day_path'.RD),
  array(
$val['0'],
    
$val['1'],
    
$val['5'],
    
$val['9'],
    
$val['10']),
  
$str);

This is where the variable replacement happens, swapping out, for example, {url_title} with the actual URL title. We need to add our desired variable names to the first array, and the values those variables should be replaced by to the second array. Easy enough, right? So it might look something like this:

$str = str_replace(
  array(
LD.'title'.RD,
    
LD.'url_title'.RD,
    
LD.'author'.RD,
    
LD.'comment_tb_total'.RD,
    
LD.'day_path'.RD,
    
LD.'mr_wilsons_variable'.RD,
    
LD.'lindas_variable'.RD,
    
LD.'seamus_variable'.RD),
  array(
$val['0'],
    
$val['1'],
    
$val['5'],
    
$val['9'],
    
$val['10'],
    
$val['11']['avatar_filename'],
    
$val['11']['field_id_22'],
    
$val['11']['field_id_94']),
  
$str);

So {mr_wilsons_variable} will be replaced by the avatar file name associated with the author of the entry; {lindas_variable} will be replaced by whatever is in field_id_22; and {seamus_variable} will be replaced by whatever is in field_id_94. Easy, right?

How do you tell which field ID relates to which custom weblog field? The easiest way is probably to look at the URL for the appropriate custom field in the custom weblog field edit page in the control panel.

Granted, this isn’t the most elegant hack in the world, but it should be easy to move to the next version of EE (unless, of course, the EE crew has already added this feature to EE 1.5). It can be made cleaner, but that would require more explanation.

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 17 June 2006 05:49 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  10-05-2002

Why not just allow the custom fields to be used in the calendar module?

Because I’d like to be able to call my custom fields in the weblog view (things like “distance” or “recommended”)

 Signature 

http://www.modsquare.com // idm & electronic music webzine (expression engine)
http://www.fractalspin.com // hipster geek store
http://www.quantazelle.com // electronic music project
http://www.subvariant.com // electronic music record label
http://www.lizrevision.com // blog

Profile
 
 
Posted: 22 March 2007 08:10 AM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1463
Joined  09-16-2004

I’d like to bump this again, I’d really like to see this feature in a future version of EE. I cannot begin to tell you how frustrating it is not to be able to pull even a single custom field into that calender :(

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 17 April 2007 04:39 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  863
Joined  01-07-2003

Ack. . . 

Just ran into this issue today. . . . yes please add this to the next version.

 Signature 

 NetRaising is a member of the EE Pro Network

Profile
 
 
Posted: 30 April 2007 09:14 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
RankRank
Total Posts:  110
Joined  09-14-2006

I’d like to second this

Profile
 
 
Posted: 02 May 2007 10:57 AM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  2
Joined  03-20-2006

i’m unable to get Mr. Wilson’s method working. I’ve added the $row. here’s the rest:         

$str = str_replace(
                  array(
LD.'title'.RD,
                    
LD.'url_title'.RD,
                    
LD.'author'.RD,
                    
LD.'comment_tb_total'.RD,
                    
LD.'day_path'.RD,
                    
LD.'calendar_items'.RD),
                  array(
$val['0'],
                    
$val['1'],
                    
$val['5'],
                    
$val['9'],
                    
$val['10'],
                    
$val['11']['field_id_20']),
                  
$str);

I have in my template {calendar_items} listed, but it doesn’t return what is in field 20, a custom field I created.

Am I missing something??

Profile
 
 
Posted: 23 June 2007 02:14 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1506
Joined  05-15-2004

It looks like mod.weblog-calendar.php has changed in 1.6, so I am no longer sure how to implement Mr. Wilson’s hack. Is it still possible to use it?

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

Profile
 
 
Posted: 05 October 2007 04:27 PM   [ Ignore ]   [ # 14 ]  
Grad Student
Avatar
Rank
Total Posts:  96
Joined  11-29-2006

I need the {count} variable too, could anybody help us? smile

Profile
 
 
Posted: 05 October 2007 07:51 PM   [ Ignore ]   [ # 15 ]  
Grad Student
Avatar
Rank
Total Posts:  96
Joined  11-29-2006

Good news! It still works.

For EE 1.6:

In modules/weblog/mod.weblog_calendar.php find:

$out = str_replace(LD.'day_number'.RD, sprintf($day_num_fmt, $day), $out);


Immediately below that, add:

$out = (isset($data[$day])) ? str_replace(LD.'count'.RD, count($data[$day]), $out) : str_replace(LD.'count'.RD, '0', $out);

Profile
 
 
Posted: 04 January 2008 12:40 AM   [ Ignore ]   [ # 16 ]  
Summer Student
Avatar
Total Posts:  8
Joined  10-30-2007

Friendly bump ... would be great to see this feature, really, such a no brainer!

Profile
 
 
Posted: 04 January 2008 06:47 PM   [ Ignore ]   [ # 17 ]  
Grad Student
Avatar
Rank
Total Posts:  96
Joined  11-29-2006

Hmm.. I think it’s already integrated in version 1.6.1 (Changelog):

Added {count} and {total_results} variables to Weblog Categories tag

Profile
 
 
Posted: 04 January 2008 06:52 PM   [ Ignore ]   [ # 18 ]  
Summer Student
Avatar
Total Posts:  8
Joined  10-30-2007

and custom fields? I was told yesterday NO .... I have already wirtten an article on mr wilson’s hack .. so at leats people in future will more easily find the answer and have easy instructions.

Profile
 
 
   
1 of 3
1
 
‹‹ Plugin Editor      {path=logout} parameter ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65074 Total Logged-in Users: 35
Total Topics: 82206 Total Anonymous Users: 14
Total Replies: 441803 Total Guests: 193
Total Posts: 524009    
Members ( View Memberlist )
Newest Members:  mackskithbtggAdminempoleongwishPasha MahardikarmarkdurandomcatClutch BearingsAdil