Applying CSS only to table in Single Upload Form Applying CSS only to table in Single Upload Form
 

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

Applying CSS only to table in Single Upload Form

Started by EME, December 30, 2016, 10:15:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EME

I am trying to shrink the width of the table on the single upload page and remove cell borders.  I have accomplished it by adding the following CSS to style.css in the Water Drop theme:

   form#cpgform table {
       border-collapse: collapse;
       width:50%;
   }

However, I discovered when testing the site after this change that it has applied the css to other tables throughout the site, such as the one activated by the admin's config button.  That sent me looking through upload.php to see what the HTML looked like.  Around line 731 I found an instance of the function starttable which looks to be generating it:

    // Open the form table.
    starttable('100%', $upload_table_header, 2);

That function is defined around line 4047 of themes.inc.php:

    // Function to start a 'standard' table

    function starttable($width = '-1', $title = '', $title_colspan = '1', $zebra_class = '', $return = false)

By changing the value of $width in the above-mentioned instance in upload.php I am able to get the width where I want it.  But from what I can see the function does not support inline CSS.  So I can't apply border-collapse: collapse.

I did figure out that I can add a class to the single upload form by rewriting the function as follows:

    // Open the form table.
    starttable('100%', $upload_table_header, 2, 'uploadtest');

That then allows me to apply CSS to the single upload page with the following:

   form#cpgform table.maintable.uploadtest {
       border-collapse: collapse;
       width:50%;
   }

My question has two parts:

1) It looks like adding the class where I did is only applying it to the single upload page.  Testing has so far supported that.  But I don't know your system terribly well.  Is that class being applied somewhere else that I don't see at the moment?

2) Is there a way to execute this change without altering the core file upload.php? I am not terribly familiar with how Coppermine themes work.  Ideally it is best to change stuff like this inside the theme, and the installation I'm working on already has several core changes.

phill104

Not able to give you the exact location as I am responding on a windows phone. What you would normally do is apply the required changes in theme.php. In the waterdrop theme this file only contains a few elements that override the default. So to add the block you need to change you copy the block you need from the sample theme as that contains everything.

This section of the docs explains this in more detail paying particular attention to the links in the what's next section  - http://documentation.coppermine-gallery.net/en/theme.htm#theme_engine

If you still need help hopefully one of the team or community can assist as I am away from home for the next few weeks.

It is a mistake to think you can solve any major problems just with potatoes.

ΑndrĂ©