0

I'm pretty new to Drupal but have take my company's half-baked site from the server and gotten a working instance of it in my local wamp stack working. The only problem is that it seems on every page there is a section of code being inserted:

<?php
if ( isset($entity->field_job_id['und'][0]['safe_value'] )) {
   $job_id = $entity->field_job_id['und'][0]['safe_value'] ;
   $application_link_form = '
<form action="/careers/application" method="POST">
    <input type="hidden" name="job_id" value="' . $job_id . '" />
    <input type="submit" value="Apply online" class="job-application-link" />
</form>';
   print $application_link_form;
}
 ?>

This is showing a section of this code plus an "Apply Online" button at the top of each section of content. It doesn't seem to matter what the content type of the content and the site which I imported all the files and db from has no such code - not even when I view source is there anything even commented out. Hopefully this code gives you some context as to where this is ocurring - it comes immediately following this series of divs:

<div class="region region-content">
  <div id="block-system-main" class="block block-system">
    <div class="content">
      <div class="contextual-links-region"><div class="panel-display panel-1col clearfix" id="job">
        <div class="panel-panel panel-col">
           <div> 
              <div class="panel-pane pane-dsc" >
                 <div class="pane-content">

In any case, I cannot figure out where to find this code in order to get rid of it. I'm not seeing any modules relating to this, etc. And I just am baffled as to why it would start showing up after importing from a site that doesn't display this. If anyone can think of any possibilities, please let me know!

  • Have you tried finding the code? With grep, or an IDE, or any other search tool? – Letharion Feb 28 '13 at 15:25
  • Thanks for the suggestion. I just searched on numerous pieces within the code, includign "job_id" "/careers/application" "application_link_form" etc., and come up with nothing - searching within c:\wamp\www. – Levi Wallach Feb 28 '13 at 15:39
  • PHP code in a Custom Content Panel pane?? – Chapabu Feb 28 '13 at 16:33
1

If it's not in the source, it's in the DB. At a guess, this is code that someone entered using the PHP filter, but the PHP filter is not active so it's showing up as text.

As to where it is in the DB, there's many possibilities. I'd use brute force to search the DB in its entirety. (That's easy for me to say as I have a copy of SQLyog to hand. I'm sure there are other tools that provide this functionality, though: I think PhpMyAdmin has it.)

Addendum: looks like it's in a custom pane, so the table panels_pane is the most likely culprit. Ideally you want to find how it's getting inserted onto the page. Do you have the module Panels Everywhere enabled?

  • drush sql-dump | grep makes such a search trivial almost everywhere :) (Except on windows of course) – Letharion Feb 28 '13 at 15:57
  • It's being loaded as a block I think so admin/structure/blocks should help you locate it and disable it. It's a very bad idea to have PHP in a block. – Alfred Armstrong Feb 28 '13 at 16:01
  • Thanks. I used phpMyAdmin and the only reference to job_id was a row in the webform_component table. I also looked in the filter module. The only difference between my version and the one on the server for that is that the one on the server is as follows. Both have an entry for Display Suite but when going in to configure those, on the server there is a checkbox (checked) for Display Suite Evaluator whereas that does not show up for the local instance. The Display Suite module I have locally is more recent then the one on the server. Should I try to remove it and install an earlier version? – Levi Wallach Feb 28 '13 at 16:40
  • Sorry, I did not see your addendum. Panels is enabled for Node Template Home, and Job openings. Is that helpful? – Levi Wallach Feb 28 '13 at 17:41
  • Ok, I drilled down into the Note Template and in the preview I get the exact code that is coming through. Here's the url that I'm at: localhost/admin/structure/pages/nojs/operation/node_view/…. So the question is, how do I get this not to show? – Levi Wallach Feb 28 '13 at 17:56
0

I consulted a Drupal expert in our company who looked through the instance. He diagnosed a couple of causes. For one, the PHP Filters module was not enabled. Additionally, I needed to set the PHP Evaluator option for "Display Suite Code" (in Configuration > Content Authoring > Text Formats > Display Suite Code). These two items fixed the issue.

According to him, the code was in the panels in order to display an Apply Online button conditionally above some content. He thought it was unnecessarily complex to do it in the way the previous Drupal Dev did it. Being a newb, I wouldn't presume to offer my own opinion. ;-)

-1

As Alfred says, it's going to either be in the code or the database.

If you have the sql data dump, you can open that in a text editor and search for the code.

The fact that it's found here in your html

<div id="block-system-main" class="block block-system">
  <div class="content">

... leads me to think that it's a block within your content region that's injecting this code.

Go to Admin > Structure > Blocks and see what blocks are enabled in the content region, try disabling them.

  • The block-system-main block is the system block that contains page content. It's not actually a real block per-se. – Chapabu Feb 28 '13 at 16:24
  • Only one block is enabled and changing that had no effect. – Levi Wallach Feb 28 '13 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.