Hi there,

I'm using colorbox inside the node. The issue is when inside the colorbox I'm trying to generate an

 <script>
                              jQuery('a.reference<?php print $i ?>').colorbox(
                                {
                                  opacity:0.25,
                                  html:
                                  "<div><strong>Book Title: </strong><?php if (property_exists($noderef, 'field_references_booktitle')) {print $noderef->title_field['und'][0]['value'];} ?></div>"+
                                  "<div><strong>Author: </strong><?php if (property_exists($noderef, 'field_references_author')) { print $noderef->field_references_author['und'][0]['value']; }?></div>"+
                                  "<div><strong>Year Published: </strong><?php if (property_exists($noderef, 'field_references_year_published')) {print date_format(date_create($noderef->field_references_year_published['und'][0]['value']), 'Y'); }?></div>"+
                                  "<div><strong>Publisher: </strong><?php if (property_exists($noderef, 'field_references_publisher')) { print $noderef->field_references_publisher['und'][0]['value']; }?></div>"+
                                  "<div><strong>City Published: </strong><?php if (property_exists($noderef, 'field_references_city_published')) {

?><a href=<?php print $noderef->field_references_city_published['und'][0]['value'];?>>Link</a> 

}?></div>",
                                  width: "20%"
                                });  
                            </script>

The line below is generated when render with the Link text outside of the anchor tag, for that reason it is imposible to click:

<a href=<?php print $noderef->field_references_city_published['und'][0]['value'];?>>Link</a>

field_references_city_published is a text field in the CMS.

I think it is also important to say that if I change $noderef->field_references_city_published['und'][0]['value'] for an URL hardcode works correctly, and also is important to say that the value of field_references_city_published is there when I inspect.

Do you have any idea why that is happened?

Comments

benjus’s picture

When I inspect the code resulted is this:

Link

VM’s picture

something isn't quite right with your code tags around your original post or the comment.

benjus’s picture

Hi, why do you think that? That code is only a part of the page but it is working, no entirely the

VM’s picture

cod tags around your code in your posts. scroll up ... it's partially unreadable and is trying to act as a link when hovering over it which tends to indicate that a code tag isn't properly placed.

benjus’s picture

Ok, let me see if with this other example is better (I tryed to indent the code to have clearly vision) :

<!--Check if reference is an archive -->
<?php if(isset($noderef->field_references_archive_name['und'][0]['value'])): ?>
    <?php if(!empty(render($content['field_cas_archnz_id'][0]))): ?>
           <?php $aux = render ($content['field_cas_archnz_id'][0]);
                    $aux = substr($aux, 1);
                    $aux ="https://www.archway.archives.govt.nz/ViewFullItem.do?code=".$aux;
           ?>
     <?php endif; ?>
     <script>
          jQuery('a.reference<?php print $i ?>').colorbox(
            {
       opacity:0.25,
       html:
       "<div><strong>Archive Title: </strong><?php if (isset($noderef->title_field['und'][0]['value'])) {print $noderef->title_field['und'][0]['value'];} ?></div>"+
        "<div><strong>Archive URL: </strong>
                      <?php if (isset($noderef->title_field['und'][0]['value'])) {?>
                                <a href =  <?php print $aux; ?>>Link to Casualty</a> 
                                <?php }?>
           </div>
           <div><strong>Archive IE URL: </strong>
                       <?php if (isset($noderef->title_field['und'][0]['value'])) {?>
                                <a href =  http://ndhadeliver.natlib.govt.nz/delivery/DeliveryManagerServlet?dps_pid=<?php print render                          $content['field_cas_archnzie_id'][0]); ?>>Link to IE</a> 
                       <?php }?></div>",
                                  width: "20%"
                                });  
                            </script>
                        <?php endif; ?>