Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
phantastes CreditAttribution: phantastes commentedI have the exact same issue. Any thoughts on how to solve this?
Comment #2
phantastes CreditAttribution: phantastes commentedHi,
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:
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.
Comment #3
radeg CreditAttribution: radeg commentedHello Phantasies, add the line indicating the problem and solution.
Thank you.
Comment #4
phantastes CreditAttribution: phantastes commentedHi,
I've added comments in the code to show what I've added.
But here it is:
Code that causes problem:
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:
I hope this helps!