Forums  ›  General  ›  General discussions
 

Random Featured Public Photos Block Home Page

Thanks Deano. 

If I remove Public Photos, the Featured images are displayed full size (750 or 750) and not positioned correctly.

Now i get it. I just did the same, and see the bug. So i will find a fix for that also.

Thanks Deano. I do check the repo regularly hoping for the odd "GEM" or two.

The rest is just meant to confuse you:

I have the block working perfectly on my site, but to do so, I must also have the Public Photos block running as well. It doesn't need to be in the same column, but it must be on the page. If I remove Public Photos, the Featured images are displayed full size (750 or 750) and not positioned correctly.

I mentioned it worked fine on the clean install. However, I decided to move the block to another column and a similar problem appeared there as well.

I'll wait for the official code because I do think it's a great addition to the script.

Make sure you removed any source code changes made for that other block you were using from the boonex forum.

I am currently working on more changes to my block as well a fixes to the one on the photos page for bugs i found. I will be posting those to the repo when i am done because i am making that block a built in block in cheetah.

When i have finished that, i will tell you what to do to get those updates.

I thought everything was perfect, but when I transferred the block to my working site, all hell broke loose. It worked perfectly on the test site, but on the working site:

  1. small photos are flush lef
  2. Large photos are not reduced or constrained.

It took me hours to find why it was working on one of two almost identical sites. The reason was: I had installed the modified Boonex random public photos on the test site. When I removed the block, the above problem returned. The block "must" be installed and it "must" be activated" for your snippet to run properly.

I then installed the snippet on a clean install of Cheetah and it works perfectly without and support from other blocks:

Somewhere someone, possibly me, has introduced a gremlin. As I don't wish to use the Public Photos Block on my site, I need to fix the problem if possible.

 

Ok. I am off to work now.

 

I tried it on a clean install and there weren't any issues on the photo page.

It looks like a module is causing the problem. I'm not able to fix it with css because I can't find where the 700px is being inserted. As I don't plan to use the block on the photos page, it isn't an issue.

Thanks for your help.

I votes on the photo block on the photos page would have to be edited elsewhere. That's how the default block works on that page.

I saw your code update after I posted my last message. I'm trying it now.

There were two unknown featured pics. Both were 1600 x 800 which is over the set size limit. I deleted those, plus a pic which was marked as a profile pic. More cache cleaning and things are looking good. I'll add more photos to see it stays that way.

The code snippet fixed the voting stars, but . . . 

I've never used the random photo block on the photos page before, so I tried it. The same problem with the Votes is there as well and the photos were from everywhere until I fixed the database.

Here's a screenshot on the default template. I don't see any difference in the layout. I've fuzzed the photo and name only. I'm happy.

I think I have a clean install somewhere. I'll try the supplied Random photo block on the photos page there.

I updated the code. Use this instead. I just discovered the code may or may not work depending on where it is on the page and if another photo block of some type is also on the page. The new code fixes that.


UPDATED CODE.

require_once(CH_DIRECTORY_PATH_MODULES . 'cheetah/photos/classes/ChPhotosSearch.php');
$sClassSearch = 'ChPhotosSearch';
$oSearch = new $sClassSearch();
$oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status', 'albumType', 'ownerStatus'), array('albumsObjects', 'albums'));
$oSearch->aCurrent['restriction']['featured'] = array(
    'field' => 'Featured',
    'value' => '1',
    'operator' => '=',
    'param' => 'featured'
);
$oSearch->aCurrent['paginate']['perPage'] = 1;
$oSearch->aCurrent['sorting'] = 'rand';
$aFiles = $oSearch->getSearchData();
echo str_replace('ch-def-bc-padding', '', $oSearch->getSwitcherUnit($aFiles[0], array('showLink'=>1, 'showRate' => 0, 'showDate' => 1, 'showFrom' => 1)));

You should also view that block in the default template. I think your CSS is messed up. It does not look like that block is displaying properly based on your pic.

Look for 'showRate' => 1 in that code i provided and change the 1 to 0.

As for the other issue.

Run the following command in phpmyadmin.

SELECT * FROM `ch_photos_main` WHERE `Featured`=1

That query will show a list of all photos that have the featured flag turned on. The block should only be showing those.

Thanks Deano,

The bock works, but there are issues:

  1. I only have two or three photos marked 'featured', yet the block is showing mostly non-featured photos including photos from "Friend's Only" albums. I never feature those.
  2. The Votes Stars appear to the right of the block. I really don't need these.

This block will be great for me, but running both blocks drawing on "Featured" pics on the home page will tend to duplicate things. I actually prefer this block to the standard multi photo block, so I'll be happy if you make the other a work in progress. (Just me talking)

This is the code for the single photo random block. This code is to be placed in a php block. So you will need to have the php block in page builders option turned on.

Drag a PHP block into the home page and paste this code into it.

require_once(CH_DIRECTORY_PATH_MODULES . 'cheetah/photos/classes/ChPhotosSearch.php');
$sClassSearch = 'ChPhotosSearch';
$oSearch = new $sClassSearch();
$oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status', 'albumType', 'ownerStatus'), array('albumsObjects', 'albums'));
$oSearch->aCurrent['restriction']['featured'] = array(
    'field' => 'Featured',
    'value' => '1',
    'operator' => '=',
    'param' => 'featured'
);
$oSearch->aCurrent['paginate']['perPage'] = 1;
$oSearch->aCurrent['sorting'] = 'rand';
$aFiles = $oSearch->getSearchData();
echo str_replace('ch-def-bc-padding', '', $oSearch->getSwitcherUnit($aFiles[0], array('showLink'=>1, 'showRate' => 0, 'showDate' => 1, 'showFrom' => 1)));

Edit the blocks caption to what you want.

The other block type i am working on will take a lot more time.

I am working on a couple of different block types. One just displays a single random featured photo. Similar to the latest featured photo block on the photos page.

The other will be a block that can be customized as to how many squared photos it will display. Similar to the members block on the home page but with random featured photos instead.

I have the code for the single photo block done. The multi photo block will take much more time to complete.

Ok. I'll work on a random featured photos block. It will take a bit of time. I'll see what i can come up with.

 

A single photo was my preference, but I'm more or less able to do that using an HTML block and selecting a pic.

I'm now attempting  two things:

1. Create a block for the most active member.  This is a simple HTML block as mentioned and I'm choosing them from my observation. The purpose is to encourage members to participate instead of just looking.

2. Create a block of Random Featured photos on the home page. The current Public Photos block with Top or Latest, doesn't make the grade. The latest photos are duplicated in the timeline or outline opposite and the top photos never seem to change. (Maybe a bug, but they haven't changed for a year.)

So, I'm no longer looking for assistance with item (1) because it would be a complex module if done properly. I would love to make item (2) random featured photos if possible.

Oh. Ok. I was not aware it was using the default photos block which shows 9 photos by default.

I for some reason was under the impression you wanted a separate block that would show 1 random featured photo.

I will play with this after i get out of work tonight.

 

Hi Deano. I've sent you a PM.

John

You would need to change the code you now have to get featured photos only. If the code is pulling from the database table ch_photos_main, the you need to alter it to pull only those that have a 1 in the featured column of that table.

If you could send me the code, i can play around with it.

I used a very old post on the Boonex forum to make the Public Photos block on the home page show random photos. It works well, but the dropdown still shows Top and Latest instead of Random/Top/Latest. It doesn't matter because Random is the default. The boonex code is a bit messed up but if anyone is interested, I can tell you what you need to change. It's a ten minute job.

I need to draw these photos from "Featured" because some are public photos on my site are pretty bad. I really don't care if Random/Top/Latest are all featured, in fact that may be a good thing.

Where can I add some code to make this magic happen?