Questions about PHP not related to Drupal should be asked on Stack Overflow. Don't use this tag to generally mean "the question is about PHP code."

learn more… | top users | synonyms

2
votes
1answer
6k views

How to change error-message displayed @ failed form-element validation to be different than the element's '#title" text?

I'm writing a custom form module. Using Drupal7's FormAPI, I create a checkbox, the label/text diplayed next to it is set as described here ...
0
votes
2answers
2k views

Extending Drupal Functionality to Custom PHP Page

I have Drupal 7 site which is working fine. I added a custom PHP page to my site in the root directory of it. I want to extend the Drupal application functionality to that one page so that I can have ...
3
votes
3answers
1k views

Write all PHP errors, warnings and notices to error_log

Drupal catches PHP warnings and notices to log them via dblog or syslog. As a result, there are two places to monitor for PHP errors (with the watchdog UI not well suited to cater for any large number ...
1
vote
2answers
10k views

Unable to send e-mail. Contact the site administrator if the problem persists

*hostname.domain.com is substituted throughout for my actual subdomain* My Setup I have Drupal 7.14 on an OpenVZ VPS running Ubuntu 11.10 (also tested with 10.04). Ubuntu has installed the ...
1
vote
2answers
447 views

First page load/execution slow, login slower Drupal 7

Drupal 7 site experiencing slow execution/load time for first page visit and slower execution/load time for login. The web server and database servers are dedicated and well resourced, the site has no ...
-2
votes
1answer
57 views

how to highlighted clicked taxonomy term

I am using below code : echo "<h1>".Volume."</h1>"; $tid=db_query("SELECT th.tid FROM taxonomy_term_hierarchy th INNER JOIN taxonomy_term_data td ON th.tid=td.tid INNER JOIN ...
5
votes
2answers
3k views

How do I programatically submit a webform via drupal_form_submit?

Drupal 7, Webform 3 I want to programmatically submit a webform via drupal_form_submit. However, I'm having difficulty finding a $form_state structure that works. I've submitted my webform via the ui ...
4
votes
1answer
177 views

How to hide rating field when adding comment to own node?

On my website, users can rate nodes with the Fivestar module while adding a comment. In other words, the rating field (called 'stars') is part of the comment. Now, I'd like to hide the rating field ...
3
votes
2answers
5k views

Warning: Cannot modify header information - headers already sent

My log is cluttered with this message: Warning: Cannot modify header information - headers already sent by (output started at /home/path/to/drupal/7/includes/common.inc:2681) in drupal_send_headers() ...
1
vote
1answer
172 views

How to detect when a user navigates to a taxonomy term page and access that terms data?

I'm making a custom directory navigation using the PHP code filter, and putting the code in a block. I need to detect when a user navigates to a taxonomy term page, and extract data related to the ...
0
votes
1answer
112 views

Add and customize login block on page.tpl

I'm trying to add the user login block in my page.tpl file. I've tried inserting the following code but the only thing I see is the username, password and submit fields. The "Register" and "Forgot ...
0
votes
1answer
315 views

Problems with permanent caching in drupal

My requirement is to update some params in the script for a some specific nodes. If a set of nodes is attached to an X content type, it should take some params in a script. For this purpose I am ...
0
votes
3answers
419 views

Responsive not working after converting html theme to Drupal theme

While trying to convert a HTML responsive theme to Drupal 7 theme, it's responsive is not working!!! Can anyone help me with this to sort the issue? We have copied Bartik theme and removed the CSS ...
4
votes
3answers
802 views

How to find all inputs that make use of the php input filter to fully disable the php filter module?

I want to disable the PHP Filter module on a large website, but going through all nodes, blocks and other fields where you could make possible use of the php filter would take eons. Is there a simple ...
8
votes
1answer
5k views

How can I insert PHP code in Views?

I tried the views_php but I have no luck. Any link to its documentation? I want to add some custom field with PHP code inside it but the one I did return nothing. Please see the attached picture.
2
votes
2answers
2k views

Adding classes to block title

I have a block which template I'm overriding with my own. The title in it is displayed by the following code: <h2<?php print $title_attributes;?>><?php print $title; ...
2
votes
1answer
3k views

Drupal 7 Image Styles Generate

I am running a Drupal 7 site that does a call to an external service using Feeds Module, creates nodes from that coming JSON. The Feeds Module grabs an image, download it, and generate 4 different ...
1
vote
2answers
133 views

PHP Output in module

I am creating a module that is outputting a static php page into my Drupal install. Here is my module file: <?php function mymodule_menu() { $items = array(); ...
0
votes
1answer
644 views

How can I change an image field programatically?

I'm trying to change the image field 'Badge' when an article is situated at the top of a view 'Top 3' after it has been updated. This is my custom module: function top_node_update($node) { $top = ...
2
votes
2answers
319 views

Trying to make a custom region disappear upon user login, then reappear when user logs out

I've looked everywhere for an answer to my problem, but can't find one. My goal is to collapse/force a custom region on my website to disappear when a user logs in, and then have it reappear when the ...
2
votes
3answers
190 views

What's wrong with the way I use variables in my function?

I have a function that looks like this: function mymodule_privatemsg_message_validate($message) { $uid = $vars['message']->author->uid; //if root or help user, message should always go ...
2
votes
3answers
1k views

How to render a poll within a node?

I'm trying to embed a poll into the body of a node with PHP code: $node = node_load(123); print node_view($node, 'full'); That won't work. What's the trick?
2
votes
1answer
547 views

IS there a replacement for 'taxonomy_node_get_terms_by_vocabulary' in Drupal 7?

The closest I have come is taxonomy_term_load_multiple but the conditions argument will be deprecated in V8. They now recommend EntityFieldQuery as a replacement. I am new to coding and have not ...
1
vote
0answers
61 views

How to create custom slider using Drupal(PHP) & Jquery? [closed]

I want to create a slider of images using Drupal(PHP) + Jquery. I was able to achieve this but get stuck in the error which is mentioned in below post:- Not able to overwrite old value in ...
1
vote
1answer
46 views

How to get uid from a node on which is commented?

I'm using hook_comment_view($comment) and I'd like to confer the uid from the comment ($comment->uid) with the uid from the node on which is commented. I thought of $node->uid, but I don't know ...
1
vote
2answers
82 views

How to change a user image field to a completed goal image (programatically)?

I created several goals with the Goals module. Every goal has an associated image. My users have an image field 'Last goal' and I'd like to change it to the image associated with their latest ...
1
vote
1answer
60 views

I cannot see the Rules event “Page is going to be viewed”

I am looking for rules event "Page is going to be viewed" but I cannot see it; is there something I am missing? I'm using rules 7.23, I have panels enabled, and I want to use it to redirect ...
1
vote
2answers
280 views

How to hide Fivestar rating field after first comment?

The accepted answer on How to limit a user to one vote when using Fivestar? doesn't work for me, but the author hasn't provided a solution yet, so I felt this is worth a new question. My goal is ...
1
vote
3answers
2k views

Programmatically execute FEED import

The situation is I can successfully import remote content using the FEEDS module by manually clicking the import button. I need to execute the import process from code, either from a module or ...
1
vote
2answers
2k views

Create a node using services with PHP

I want to add a new page node using drupal services and REST server. $postdata = http_build_query(array( 'type' => 'page', 'title' => 'aaa', 'field_test[en][0][value]' ...
1
vote
1answer
312 views

Hide Profile2 fields depending on it's value when viewing user profile

I am relatively new to drupal and for days I'm stuck. I need to hide fields from the user profile page when they have a specific value. Adding a CSS class would also do it. But I prefer deleting the ...
0
votes
2answers
83 views

Okay to use PhP include() in body of basic page? [closed]

Aside from the usual warnings about using PhP, which I understand and am taking seriously, is there any drawback to using the PhP include() function in the "Body" box of the "Edit Basic page" form? ...
0
votes
1answer
112 views

Views Php how to select actual term name not term ID

How to select term reference field with variables in views global PHP field? I need to not Term ID, but actual term name. My views is fields of a content type that contains term reference field. And ...
0
votes
1answer
125 views

How to get the highest value of a specific field in a multivalue field collection

How to get the highest value of a specific field in a multivalue field collection, USING PHP? This is about displaying the right discount for a marketplace product. There is a node type Product with ...
0
votes
1answer
121 views

Drupal memcache is not updating cache values sometimes [duplicate]

I am fighting with this issue since last week.I need to cache some set of values in which each value belonging to specific id on every cron run.I am setting the expire time to "CACHE_PERMANANT" and ...
0
votes
2answers
6k views

If drupal is NOT front page [closed]

I would like to use the opposit of this statement: <?php if(drupal_is_front_page()) { So that the code I want to display is displayed on all pages EXCEPT the homepage. drupal_is_not_front_page ...
0
votes
0answers
1k views

Installed TCPDF and encountering PHP Fatal error: Cannot use object of type REPORT_PDF as array

I am using Drupal version 7.18 and have installed TCPDF package in my library under /var/www/html/drupal-sites/all/libraries Everything is working well for my generated pdf report. However, when i ...
0
votes
1answer
1k views

Drupal 7 views: Get NID in views using contextual filters

Does anybody know how to get the nid from a node using contextual filters or filter criteria in views WITHOUT using "Get id from url"? I was thinking about using PHP or getting it from a node-field. ...
0
votes
1answer
2k views

How to get exposed filter dropdown option selected value in drupal hook

I'm trying to get exposed filter selected value in hook_form_alter(). myModule_form_alter(&$form, $form_state, $form_id) { if ($form['#id'] == 'views-exposed-form-view-id-display-id'){ ...