Hello:
I have the following problem: When I add a field to upload images on content type Story. Using CCK and FileField.

On the home page this error:
warning: strpos() [function.strpos]: Empty delimiter in /home/citycas/public_html/sites/default/themes/inf08/template.php on line 92.

I hope your help.
I tried using another theme and do not get this error.

Details of the Line 92 in my templates.php:

      // experimental code to handle CCK fields
      foreach ($content as $key => $value) {
        if (substr($key, 0, 6) == 'field_' && strpos($vars['content'], $vars[$key . '_rendered']) !== FALSE) {
          $content['cck_' . $key] = array(
            '#weight' => $content[$key]['#weight'],
            '#value' => $vars[$key . '_rendered'],
            '#title' => '',
            '#description' => '',
          );
        }
      }
      
      inf08_prepare_content($content);

      $vars['content'] = drupal_render($content);

Comments

phantastes’s picture

I have the exact same issue. Any thoughts on how to solve this?

phantastes’s picture

Hi,
after tinkering with this for a while I believe I have a solution. I am no PHP coder so if anyone sees something wrong with this code then please correct me. The issue is caused by a user not having permission to see a cck field. When giving the user permission to be able to view the field the error does not show. BUT of course there are times when you do not want a user to be able to see a field.

So this is what I did:

           // experimental code to handle CCK fields
            foreach ($content as $key => $value) {
                if (!empty($vars[$key . '_rendered'])) {//added by phantastes
                    if (substr($key, 0, 6) == 'field_' && strpos($vars['content'], $vars[$key . '_rendered']) !== FALSE) {
                        $content['cck_' . $key] = array(
            '#weight' => $content[$key]['#weight'],
            '#value' => $vars[$key . '_rendered'],
            '#title' => '',
            '#description' => '',
                        );
                    }
                }//added by phantastes
            }

I added the "if (!empty($vars[$key . '_rendered'])) {" line and of course the closing "}".

Let me know if this solves it for you.

All the best.

radeg’s picture

Hello Phantasies, add the line indicating the problem and solution.

Thank you.

phantastes’s picture

Hi,
I've added comments in the code to show what I've added.

But here it is:
Code that causes problem:

if (substr($key, 0, 6) == 'field_' && strpos($vars['content'], $vars[$key . '_rendered']) !== FALSE) {

I believe it's the "$vars[$key . '_rendered']" bit that is the trouble maker. When it returns nothing you have the issue with the empty delimiter.

So I surrounded that if statement with this check to check that $vars[$key . '_rendered'] is not emtpy:

 if (!empty($vars[$key . '_rendered'])) {

   your code here

}

I hope this helps!