number of thumbnails in a row is based on browser width number of thumbnails in a row is based on browser width
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

number of thumbnails in a row is based on browser width

Started by nickfzx, March 06, 2007, 05:02:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nickfzx

I would love this:

the number of thumbnails in a row grows and shrinks dynamically based on browser width.

I am fairly sure this would be possible to do as a mod.

Just edit the thumbnails.php page so that instead of looking for the Number of columns on thumbnail page value set by config it creates a value based on the width of the browser window.

I am working to redo the layout of my site and am not sure weather to stick with fixed width or move to variable width layout.

confirmation that this is possible would affect my decision to stay fixed width or go variable...so any feedback on this idea would be great  ;D

nickfzx

ok so I have looked into this a little:  Please correct me if I am wrong on any of these things

basically coppermine gets the number of thumbnails in a column from the databases config section by calling this code:

$CONFIG['thumbcols']

So what I would do is a find and replace for this database call and replace it with a variable that is set by this javascript:

<script>
window.onresize = myResize;
function myResize() {
  if (document.all)
    {alert(document.body.clientWidth);}
  else
    {alert(window.innerWidth);}
}
</script>


haven't tried this javascript but I am guessing myResize would hold the value for the current width (say 800 pixels) then all I would have to do is decide how many thumbnails columns there should be.

could be done with if and else statements:

if myResize = 200 to 400 then thumbcols = 2

else if myResize = 401 to 600 then thumbcols = 4

else if my Resize = 601 to 800 then thumbcols = 6

I have very low confidence when it comes to coding and very little knowledge of syntax so I would be very grateful if someone would tell me if I have got something horribly wrong with my reasoning.

The only major flaw I can see is that I think you would have to refresh the page every time you changed the browser width to see the difference...it would be better if a refresh wasn't required and it did it in real time.

Nibbler

PHP is run by the server. Javascript is run by the browser. You can't mix them like that. I'm sure what you are requesting is possible but I don't think it will be easy or worth adding to the core.

nickfzx

I don't think it will be worth adding to the core either

this isn't a core feature request more a help-me-with-building-this-feature-request

are you saying that if the javascript is in the header of the template file for example that varaibles set by the javasript will not be able to be called inside of files such as thumbnails.php and index.php ?

and that this is due to the php being run on the server and therefore won't be able to see the javascript ?


+ I have a new idea that would give a similar effect and should cut out the server...here it is :)

there is a set number of columns and rows set by coppermine so i don't alter that.  say it is 8.

But then javascript is used to decrease the number of visible columns as the browser gets thinner...this wouldn't require any server use at all...all in browser.

Even better is if it would decrease the columns and then increase the rows so the same number of thumbnails are always shown but as the browser gets smaller and smaller it eventually becomes a long downward list of thumbnails instead of a grid.

any thoughts on this...is it a better approach?

Joachim Müller

Quote from: nickfzx on March 06, 2007, 06:11:45 PM
this isn't a core feature request
Then why did you start your thread on the feature requests board in the first place? Only requests for features that you'd like to see in future Coppermine versions is suppossed to be posted in the feature requests board.
Do-my-homework-and-code-custom-mods-for-me threads are not meant to go there. Your thread got moved, but don't expect much help: someone with a record as nasty as yours is unlikely to see developers rush in an create your unpaid custom mod. As suggested in previous threads: why don't you start giving something back to the community instead of asking to be spoon-fed?

nickfzx

sorry i looked through the forums and there wasn't a mod request or mod work in progress so I posted in feature request...as I think it would make a great feature for rows and columns to adapt to the browsers window.

And I am not expecting anyone to code it for me...just to read over my reasoning and say if they see any flaws.

I would help people out more if my karma ever went up like when i contribute something new, like here:
http://forum.coppermine-gallery.net/index.php?topic=38471.msg181633#msg181633
and here:
http://forum.coppermine-gallery.net/index.php?topic=39501.msg187306#msg187306
(although didn't follow correct protocol sorry)

but my karma has only ever gone down from the moment i opened my account, usually for tiny little mistakes.

I just went through all the sites on the homepage cpg and rated coppermine as 10/10 and excellent etc.

I have next to no disposable income so can't really offer to pay anyone...I could offer around $40 but that is not really worth a programmers time.

But i repeat: my question wasn't "can someone do this for me"...it was "is it possible to do?"

...because if it is then I will consider that when changing my sites layout.

nickfzx

I have actually figured this out now...it involved a bit of hacking at the theme file.

I don't think this is good practice but I removed this from the them_display_thumbnails function

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }


I then changed the thumb_cell in the theme to look like this:
<!-- BEGIN thumb_cell -->
<table style="float:left" align="left" width="250px" height="250px" cellpadding="0" cellspacing="0">
<tr>
                       <td>
<table align="center">
<tr>
<td >
<a href="{LINK_TGT}">{THUMB}</a>
</td>
</tr>  
</table>
                       </td>
             </tr>
</table>
<!-- END thumb_cell -->


I don't advise anyone do this but it does create the illusion of adapting rows and columns...what is actually happening is that there are no rows or columns and each thumbnail is in it's own separate table and is behaving like a word in a block of text and the browser is wrapping each thumbnail in the same way it would wrap text if the browser window got smaller.  This works in IE and FF, I have not tested it in safari yet.

The thumbnail column and rows attributes in config are still used to define how many thumbnails there will be on each page.