This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Where in PHP to Assign ID to Input Buttons - "Add Comment", "Preview"
#1

First of all thank you for this wonderful commenting system! Setup and customization has gone very well.

I have modified the css to fit within my site, however looking through the "Add Comment" and "Preview" input buttons, they contain no id or class and will only accept a call to globally modify all submit buttons. I have submit buttons in the rest of my site that I don't really want inheriting this.

Can you tell me in which PHP file I can modify the tags to include IDs so that I can assign ID selectors in my CSS.

Thank you for your help! Smile
Reply
#2

Hi,

The file is /comments/includes/template/form.php

There are two lines of code for the submit button. The first line (line 856) is for when the submit button is disabled, and the second line (line 858) is for when it's not disabled.

Same with the preview button, but lines 865 and 867.

I think the reason I didn't add a class or ID was because I used an inline style (which is set on line 837) to make the buttons green if the admin is detected, and I felt that the inline style may have conflicted with a class or ID.

Have you completed the interview?
Reply
#3

(30-Aug-2012, 10:23 AM)Steven Wrote:  I think the reason I didn't add a class or ID was because I used an inline style (which is set on line 837) to make the buttons green if the admin is detected, and I felt that the inline style may have conflicted with a class or ID.

Thanks so much Steven, you saved me a lot of time searching. Here are the changes I implemented on form.php and stylesheet.css for anyone who might find them useful.

First I created some new styles in stylesheet.css. The very last line & class is a slight color change for admin.

Code:
/***** Input Buttons *****/
.cmtx_input_btn{
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #fe1a00), color-stop(1, #ce0100) );
    background:-moz-linear-gradient( center top, #fe1a00 5%, #ce0100 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fe1a00', endColorstr='#ce0100');
    background-color:#fe1a00;
    border:1px solid #d83526;
    display:inline-block;
    color:#ffffff;
    font-family:arial;
    font-size:17px;
    font-weight:bold;
    padding:7px 24px;
    text-decoration:none;
}.cmtx_input_btn:hover {
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ce0100), color-stop(1, #fe1a00) );
    background:-moz-linear-gradient( center top, #ce0100 5%, #fe1a00 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ce0100', endColorstr='#fe1a00');
    background-color:#ce0100;
}
.cmtx_input_btn:active {position:relative;top:1px;}
.cmtx_input_btn_admin{color:#0F3;}

in form.php I made the following changes:

on line 837 I set the admin button var to a class

old:
PHP Code:
<?php if ($cmtx_is_admin) { $cmtx_admin_button = "color: #050; font-weight: bold;"; } else { $cmtx_admin_button = ""; } ?>

new:

PHP Code:
<?php if ($cmtx_is_admin) { $cmtx_admin_button = " cmtx_input_btn_admin"; } else { $cmtx_admin_button = ""; } ?>

For anyone who uses this note that I left a blank space before the class name between the quotes.


in lines: 856, 858, 865 and 867 I changed them to call classes instead of inline styles. Per the original code the admin css code gets called conditionally.

old:

Code:
style="<?php echo $cmtx_admin_button; ?>"

new:

Code:
class="cmtx_input_btn<?php echo $cmtx_admin_button; ?>"

You can see this in action here:
http://everything-ladybug.com/ladybug-species.html

regards,

HaleGrafx
http://halegrafx.com
Reply
#4

Thanks, I'll incorporate this into the next version.

Have you completed the interview?
Reply
#5

Many Drupal forms contain a submit button with id="edit-submit" when you don't supply one yourself, as does the Switch Theme module.
<?php
$form['submit'] = array( '#type' => 'submit', '#value' => t('Switch'));
?>
NEW Line 126:

<?php
$form['submit'] = array('#id'=>'switchtheme-submit', '#type' => 'submit', '#value' => t('Switch'));
?>
This change assists when trying to make a valid XHTML 1.0 site in Drupal as ID attributes should be unique throughout a page.

Thanks for the module, it works great.

PS: In this post, I added the php tags to each line to make the markup easier to read, they obviously aren't needed in the module file.
Reply
#6

Hi,

Did you integrate Commentics into Drupal? Would you mind posting the steps for the Implementations page.

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
29-Sep-2021, 11:41 AM
Last Post by afoster
02-Aug-2020, 10:40 PM
Last Post by Steven
10-Jan-2018, 09:58 PM
Last Post by noblues
08-Mar-2015, 05:08 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)