• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Taggly, a tag-cloud library

#21
[eluser]murphy2006[/eluser]
Hi Gavin,

It worked perfectly, thanks!
I am trying to get the above code to work with the CI Calendar class too to create the needed array that is supposed to look like the below according to the User Guide:

Code:
$data = array(
               3  => 'http://your-site.com/news/article/2006/03/',
               7  => 'http://your-site.com/news/article/2006/07/',
               13 => 'http://your-site.com/news/article/2006/13/',
               26 => 'http://your-site.com/news/article/2006/26/'
             );

Unfortunately, I get errors with the following code:

Code:
foreach($blog_days as $blog_days):
    
    $tagsArray[] = array($tags->day, $tags->url);
    
    endforeach;

I also tried this but then only the days 1,2 and 3 become links and not the chosen dates and the strange thing is that these tree days are the same, no matter what month I chose.
Code:
// Create the array for the calendar

    $data = array();
    
    foreach($blog_days as $blog_days):
    
    array_push($data,$blog_days->day,$blog_days->url);
    
    endforeach;

    // Display the tag cloud

    echo $this->calendar->generate(2008, 1, $data);

Please help, how should the code to produce the correct array look?

Kind Regards,
Daniel

#22
[eluser]wiredesignz[/eluser]
No need to ask the same question in two threads Daniel. http://ellislab.com/forums/viewthread/69878/

#23
[eluser]Gavin Vickery[/eluser]
Give this a try:

Code:
$daysArray = array();
foreach($blog_days as $day):
    $daysArray[] = array($day->day => $day->url);
endforeach;

echo $this->calendar->generate(2008, 1, $daysArray);

There where two problems with your foreach statement. The first is that you are using the same variable name for the AS statement ($blog_days as $blog_days), the second variable should be different. Also, you where only adding values to the 2D array, so the keys where being created automatically. What you need to do is assign the key and values with the => operator.

Hope that works.

#24
[eluser]murphy2006[/eluser]
Hi again Gavin,

Once again, thanks for the prompt reply!

I tried the above but now I unfortunately get the error: Array to string conversion.
It that anything that you reqognize?

Thanks!
Daniel

#25
[eluser]Gavin Vickery[/eluser]
Hmm, without seeing more of the code, I can't really figure out whats variables have which values.

What exactly are you trying to do? Could you post more complete code?

#26
[eluser]murphy2006[/eluser]
I am trying to populate the calendar displayed on my view page.
To create links to blog posts on the correct day.
It works fine with a static array (as described in the user guide) but I want to get the days/posts from my database instead.

This is what I use in the controller:

Code:
$this->db->select('*');
        $this->db->from('blogs');
        $this->db->where('user', $theid);
        
        $query = $this->db->get();
        $data['blog_days']=$query->result();

This is what I use in the view file:

Code:
$daysArray = array();
foreach($blog_days as $day):
$daysArray[] = array($day->day => $day->title);
endforeach;

echo $this->calendar->generate(2008, 1, $daysArray);

Thanks!
Daniel

#27
[eluser]Gavin Vickery[/eluser]
Ooooh, I see whats going on. You're creating a multi-dimensional array, when its expecting a single dimension.

Heres what you need to do:
Code:
// Reset array
$daysArray = array();

// Build array of specific dates for calendar
foreach($blog_days as $day):
    $daysArray[$day->day] = $day->title;
endforeach;

// Output calendar
echo $this->calendar->generate(2008, 1, $daysArray);

#28
[eluser]dawnerd[/eluser]
Thanks! I really needed one of these and was about to write my own.

#29
[eluser]murphy2006[/eluser]
Thanks Gavin, it worked perfectly fine!!

#30
[eluser]Gavin Vickery[/eluser]
Great! Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.