teeth

I'm using an awesome template from Teamwurkz. They have four components, one of which is blogs, so I was able to get that to feed into the home page via a block (core.index-visitor) in Admin CP.

Polls are not one of the four components, however.

Soooooo, does that mean I need to do it via the phpFox module? Create a new block using the phpFox poll components? If so, there's only poll.index, design and profile.

Will creating a new block with the poll.index component enable me to pull polls to show on the home page?

Thanks! Smile
Be the first person to like this.
Donna(data66)
That's perfect. Thanks. I want to figure out how to do this. How did you find that function? Also, this needs to be in the free add-ons. Do you want to put it there or shall I? If I put it, I'll put that it's your code.

I've been working on this with so many different codes. Wish there were some tutorials about how to find this information for those of us trying to learn.
Be the first person to like this.
webwolf
Well, whenever I think about how to do something, I ask myself "What would Raymond do?" Like on the new photos, I knew that they had already done that, so it would make sense that there was a call for that data. Forunately, when they programmed the code, they were consistant and logical in what they called things. In the photos it was getNew, in the videos it was getNew (with a little extra), and with polls it turned out to be the same call. If you go to the service file you may see code like:
public function getNew($iLimit = 3)


The $iLimit tell you you can select the number of records to return, but will default to 3. So they were thinking of us when they coded it.

With no other documentation, the only way that I know of learning the system is to just keep trying to figure out how things are working. It has been this way with every CMS I have worked with. (nuke, postnuke) One thing I can tell you is that it takes a whole lot of time, especially if you are as slow as I am. Sometimes when I am trying to come up with some code, I have windows open to php manual, html tutorial, js tutorial, mySql manual, wikipedia, my dev site dashboard, my dev site admincp, my dev site database, this web site and a few with which to do google searchs.

So don't be afraid to open those files and look at how Fox did them. From those examples you may be able to do the same type of thing, customized to fit your needs.
Be the first person to like this.
webwolf
Oh, and you can post this code to the add-ons section if you wish.
Be the first person to like this.
You guys rock!

Gonna try to absorb this...

Smile
Be the first person to like this.
Donna(data66)
It's in the add ons but needs approval. Do you need me to copy the instructions here?
Be the first person to like this.
Okay, so exactly where do I insert the code webwolf provided in order to have the latest polls feed into the home page? (I'm working with a customized theme/template, so I get confused as to exactly where I modify what within admincp...lol; who am I kidding, I'm just confused in general :teethSmile
Be the first person to like this.
Donna(data66)
Look in the add-ons for the detailed instructions. Smile

http://www.phpfox.com/addons/view/block-to-show-latest-polls/
Last update on February 13, 2011 by Donna(data66).
Be the first person to like this.
Hello, where has this moved to or who knows how to do this in V3? The code in this thread will only show the block with a header but with no content, can someone help.
Be the first person to like this.
webwolf
I don't think phpfox uses this call anymore. It is still in the table, but it is hardcoded to return privacy_id 1 polls (friends). If I have time, I will see if another call will work.
Be the first person to like this.
Thanx so much, I would really appreciate that.
Be the first person to like this.
webwolf
This works on my dev site:

I did this as an admincp block. The info is:

PRODUCT: phpfox
MODULE: poll
TITLE: Test Poll (or whatever you want it to be)
CONTROLLER: -- core.index-visitor
PLACEMENT: Block 1
ACTIVE: Yes
PHP/HTML Code (Optional):
PHP:
<?php

$aPolls 
Phpfox::getLib('database')->select('p.*, ' Phpfox::getUserField())
            ->
from(Phpfox::getT('poll'), 'p')
            ->
join(Phpfox::getT('user'), 'u''u.user_id = p.user_id')
            ->
where('' Phpfox::getLib('database')->isNull('p.module_id') . ' AND p.view_id = 0 AND p.privacy = 0')
            ->
limit('5')
            ->
order('p.time_stamp DESC')
            ->
execute('getSlaveRows');

echo 
'<div class="block js_sortable">';
echo 
'<div class="title js_sortable_header is_already_loaded" style="cursor: move;">Last Public Polls </div>';

foreach (
$aPolls as $aRow)
{
  
$sImg '';
  
$sImg str_replace('%s','_75',$aRow['image_path']);
  
$sLink Phpfox::permalink('poll'$aRow['poll_id'], $aRow['question']);
  echo 
'<div style="display:inline-block;vertical-align:top;"><a href="' $sLink '">'.$aRow['question'].'</a>
by ' 
$aRow['full_name'] . '</div>';
  echo 
'<div style="display:inline-block;padding-left:5px;width:56px;height:50px;">';
  if(
strlen($sImg) > 1)
  {
    echo 
'<img src="' Phpfox::getParam('core.path') . 'file/pic/poll/' 
 
$sImg '" alt="" style="max-height:50px;max-width:50px;">';
  }
  echo 
'</div><div class="clear"></div>'
}
echo 
'</div>';
//The next line was a mistake.  Please delete these two lines when you copy.
//echo '</div>';

?>


I normally don't like to do database calls in an admincp block but it was the only way I could get it to work properly.

Although this works on my site, using php blocks within the admincp can be problematic. If the code gets corrupted on your cut and paste it could cause you to not be able to access your site. If this happens you would need to go into myPhpAdmin and directly alter the table 'block' to change the 'is_active' column to 0. This will likely be the last block in the table. Then your site will come back and you can edit the bad block.

This probably will not happen, but you need to know this info in case it does.
Last update on October 15, 2012 by webwolf.
Be the first person to like this.
Thanks Webwolf. The code works like charm on core.index-visitor though when you try it on other connections like core.index-member, it "displaces" other blocks except when you put it down as the last block in a column of blocks. However thank you so much, I can make use of it.
Be the first person to like this.
webwolf
Sorry, there is an extra closing div tag at the end. Please delete one of the two lines. I will edit the code above to reflect this.
Be the first person to like this.
Thank you so much, it works perfectly well now. Excellent, keep up this level of support!
Be the first person to like this.
NetworkCycles
Thanks guys. This was just the thing I needed.

If I improve it, I will post it here.

Thanks WebWolf
Last update on October 15, 2012 by NetworkCycles.
Be the first person to like this.