0

I must preface this by saying I am a .NET developer by trade, but have recently taken a position with a company using PHP for their applications. It has been a learning experience, so please take it easy on me, and let me know if i have not followed style guidelines for posting a question.

The developer who designed and wrote this code quit recently, and I am currently the only developer we have. I know this is a really poor method for implementing this. It is incredibly poorly designed, and is written 100% inline, with no framework whatsoever. There is also no documentation, at all. I am in the process of straightening it all out and migrating the code to a Symfony platform, but for right now I have to keep this version up and running.

This <a> tag is embedded into the column in a phpGrid, and the fancybox is loaded in functions.php, which is an include from the fancyboxTest.php, which the below code is also in.

As it is written, on click it opens the fancybox as designed, but the autoScale is not working, it opens in a random size, likely because it is set to autosize, inline, and a useless scrollbar is present. I believe I need to adjust the dimensions of the fancybox overlay, but I have not had any luck doing so.

Is there a better way to do this, rather then call my javascript function using jQuery from the <a> tag, or am i simply missing something in the css? I know I cannot override the styles which are written inline, because of the rules of specificity. I have gone through numerous blog posts and articles on

which were notated in quite a few questions on this site, such as Importance of css stylesheet hierarchy

I've used generic variables, for obvious reasons.

This is the column in the grid, which the fancybox is called from:

<?php
include "../include/file1.php";
include "../include/file2.php";
include "../include/file3.php";

$db_conf = array();
$db_conf["type"] = "mysqli";
$db_conf["server"] = DB_HOST;
$db_conf["user"] = DB_USER;
$db_conf["password"] = DB_PASS;
$db_conf["database"] = DB_NAME;
$g = new jqgrid($db_conf);


$col = array();
$col["title"] = "Id";
$col["name"] = "id";
$col["width"] = "40";
$col["hidden"] = false;
$col["editable"] = false;
$col["align"] = "left";
$col["search"] = true;

$cols[] = $col;


$col = array();
$col["title"] = "Description";
$col["name"] = "description";
$col["width"] = "200";
$col["hidden"] = false;
$col["editable"] = false;
$col["align"] = "left";
$col["search"] = true;

$cols[] = $col;

$col = array();
$col["title"] = "Objects";
$col["name"] = "onjects";
$col["width"] = "100";
$col["hidden"] = false;
$col["editable"] = false;
$col["align"] = "left";
$col["search"] = true;

$cols[] = $col;


$col = array();
$col["title"] = "Image";
$col["name"] = "image";
$col["width"] = "20";
$col["hidden"] = true;
$col["editable"] = false;
$col["align"] = "left";
$col["search"] = false;

$cols[] = $col;

$col = array();
$col["title"] = "Equipment";
$col["name"] = "equipment";
$col["width"] = "40";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
/** in this column the link opens in fancybox, but is not the proper size **/
$col["default"] = "<a class=\"fancybox fancybox.iframe\" href=\"folder1/file_details.php?id={image}\"><img height=35 src='../../data/folder2/{image}.jpg'></a>";


$cols[] = $col;

/** THIS IS THE COLUMN IN QUESTION **/
$col = array();
$col["title"] = "Location List";
$col["name"] = "locations";
$col["width"] = "35";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
/** to override the fancybox inline style I am trying to use jQuery **/
$col["default"] = "<a href=\"#div\"><img height=35 src='image.jpg'>ORDER</a>";

$cols[] = $col;
/** END **/

$grid["sortname"] = 'id';
$grid["sortorder"] = "asc";
$grid["rowNum"] = 300;
$grid["height"] = "";
$grid["width"] = 1000;
$grid["autowidth"] = true;

$g->set_options($grid);

$g->set_actions(array(  
                        "add"=>false,
                        "inlineadd"=>false,
                        "edit"=>false,
                        "delete"=>false,
                        "rowactions"=>false,
                        "export"=>true,
                        "autofilter" => true,
                        "search" => false
                    ) 
                );


$g->select_command = "**{my_sql_call}**";

$g->table = "correct_table";

$g->set_columns($cols);

$out = $g->render("list1");
?>
<?php include("file4.php");?>

</head>
<body>
<?php 

include("file5.php");
 ?> 
   <div class="mainrow">
    <div >
    <?php echo $out?>
      </div>
    </div>
   <?php
</body>
</html>

the javascript function:

function openFancybox(div) {
  $(this).fancybox({
    'autoScale': true,
    'transitionIn': 'elastic',
    'transitionOut': 'elastic',
    'speedIn': 500,
    'speedOut': 300,
    'autoDimensions': true,
    'centerOnScroll': true,
    'href': #div
  }).click();
}

and the jQuery:

$('a[href=#div]').each(openFancybox);

I have gone through a dozen or more questions within this forum, very thoroughly. So far the one I found that made the most sense, but ultimately the fix which helped this person was not the key to solving my problem, was Open fancybox from function

I have also looked at http://fancyapps.com/fancybox/ and http://fancybox.net/howto

Neither of which helped me solve this problem, any assistance you could provide will be greatly appreciated!

Community
  • 1
  • 1
Jrobbie
  • 9
  • 6
  • I question the validity of that PHP snippet... – Hatchet Mar 16 '16 at 21:33
  • I think you should be more specific. why not to create a fiddle? – Adib Aroui Mar 17 '16 at 00:56
  • I'm not sure what you mean by that? I know it's a horrible way to write this but as I said, I inherited it. I'm happy to give you the context of that whole file, I will just need to edit the values and notations of course. I'm not familiar with a fiddle, I will do some research in the morning. Thank you. – Jrobbie Mar 17 '16 at 03:28
  • @Hatchet what do you mean you question the validity? What would be best for me to post to give you the context? That snippet is just one of the columns in this grid, it is not the entire file. I will put it into jsFiddle and post the link, hopefully that will help you to believe this. – Jrobbie Mar 17 '16 at 12:36
  • @Jrobbie Opening PHP tag should be ` – Hatchet Mar 17 '16 at 13:48
  • @Hatchet I apologize, I quickly typed that in, just to illustrate that I have not forgotten that tag.... There are 8 columns listed above the one i posted above, I posted the only one I felt was relavent. This grid is from phpgrid.org, and the formatting by default is a bit different than what I posted. As opposed to `$column[" " ]` they are `$col[" "]` I did what I thought was necessary to keep the code generic, obviously I didnt need to change those, and I look like an idiot for doing so. I will post a snippet, in the form of an edit to my original post to show you what I'm looking at. – Jrobbie Mar 17 '16 at 15:38

0 Answers0