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

1
vote
4answers
18 views

How to add image to only front page of drupal

I am totally noob about PHP, so i need your help with setting an image only on front-page. So for now i have this code: <div id="content-wrapper"> <img ...
0
votes
1answer
14 views

protecting a staging Drupal environment

I've been using this code block inspired by Acquia to protect a client's staging environment. if($_SERVER['SERVER_ADDR'] == '192.168.1.1') { $username = 'user'; $password = 'password'; if ...
0
votes
1answer
27 views

Displaying all fields of a custom content

I have a page.tpl.php ; where I want to display inside a <div> in it the fields of a custom content I've created before : 1)The custom content is called "Slider" 2)It have a field I've added ...
1
vote
1answer
35 views

PDO is proper way of connecting to MSSQL server database..or any standard way in drupal 7 [duplicate]

I want to connect to MSSQL server database through Drupal custom module. I need to connect to another MSSQL server database. I'm aware of the sqlsrv module, but that module does not provide ...
0
votes
1answer
15 views

Theming Views problem to print view fields

Hello Drupal Community, I was trying to edit my view theme with php in the file views-view-field--homepage-banner--block--field-site-image.tpl.php and try to print view fields, but values come's ...
0
votes
1answer
25 views

Drupal Multiupload Filefield Widget conflict with mutiselect ajax dropdown

I have created a multiupload field in my node using Multiupload Filefield Widget. I am using the code below to alter the default node form. There is an ajax based dependent dropdown field in the ...
0
votes
0answers
31 views

How to use fields in node's comment in a node's Computed field?

I'm new in php and I'm stuck with this. First problem, In a computed field of a node, I would like to use fields that are in the comments of this node. I don't know how to get access to comment's ...
0
votes
1answer
27 views

How to rewrite field with php in views?

I need to do a string replacment with php on a title field in views 3 / drupal 6.So i would to know the best way because after research i found these: use Views PHP module use Computed fields ...
0
votes
0answers
13 views

How do I get the node object in access options > PHP on a views content pane?

I have a view content pane. View is of type quiz. I want to limit the results in the view to quizzes that the logged in user has access to. My understanding of views is that the default behaviour is ...
0
votes
0answers
13 views

Programmatically set a multi value date field

$checked = array(); foreach($form['field_rundays'][LANGUAGE_NONE]['#default_value'] as $key => $val) { $checked[$key] = $val; } r($i=0;$i<count($checked);$i++){ $date = ...
0
votes
2answers
31 views

getting key of submitted entity list field

I'm having troubles with the following: I created a form with entityforms and now i want to send a confirmation email with mimemail. Getting that to work is no problem. But i need to perform a small ...
0
votes
1answer
32 views

Modal Bootstrap in page.tpl.php

Have been struggling with view and modal to display related node content for a few days, but in vain. In view, a page is to display / list only thumbnail images (Display Suite) with rewritten link ...
1
vote
1answer
28 views

drush update - php.ini problem

I am trying to update drupal using drush from Version 7.36 to 7.38 with >drush up drupal the process finishes in 2-3 seconds stating update has successfully finished and a backup has been created. As ...
1
vote
0answers
43 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 ...
0
votes
0answers
20 views

API to publish articles on Drupal

Does Drupal provide any kind of APIs to publish articles? I have Ruby on Rails application for content authoring and need to publish articles to different site which runs on Drupal
1
vote
1answer
33 views

How to get the Drush output of “drush l10n-update” from the command line with PHP in Linux?

I am trying to print from PHP the list of my updated translations, I know that I can obtain this info using drush l10n-update (I have installed the l10n-update module) from the command line but I want ...
0
votes
0answers
16 views

Is it possible to insert php values into added javascript files in Drupal? [duplicate]

In Drupal javascript files can be added for example by drupal_add_js() function, or (in my case) attached by form API: $form['#attached']['js'] = array( drupal_get_path('module', 'activit') . ...
0
votes
1answer
52 views

Web Service Client - Changing SOAP-ENV: into soap:

This is reference to issue that I have with Web service client module, here is link to the previous issue: https://www.drupal.org/node/2508926 Overall I'm trying to change the REQUEST from POST ...
0
votes
0answers
6 views

drupal commerce code to upload translated product manuals into site

PDFhow to write a code which uploads product manuals PDF's into site according to the products sku. example i want manuals according to sku,if product sku is T1234,T5678 product manual field should ...
1
vote
2answers
25 views

How to show a block on user profile edit page ?

I am trying to display a block on an user edit page (example: user/123/edit/custom_url, but for some reason, I can't seem to get it working. Any help is appreciated. I tried this, but this isn't ...
0
votes
0answers
10 views

How to get session user id in custome php file [duplicate]

I want user session id in my custom ajax file named "ajax_page.php" below is code that i have placed in that file but i am not able to get object array of $user that i'hv defined as Global $user. ...
0
votes
1answer
26 views

how to calculate a value by rules

I have three fields in a content type and want to calulate sum of them in another field. First, I use Computed Field but it does not work at all. Then I tried to use conditional field but it is not ...
0
votes
0answers
18 views

Check if text contains internal url

I have a text field where users can submit text. I would like to restrict possible urls only to urls that are on same domain. Is there any function that would check if such the url belongs to a node? ...
0
votes
0answers
9 views

Drupal 6 Track step by step performance / execution time

Drupal 6 site is slow. Want to track performance / page execution time. - check each step, PHP code, execution time - check JavaScript execution time - check CSS execution time Krumo prints out the ...
2
votes
2answers
48 views

What is the best way to add my custom PHP functionality to a Drupal homepage?

I have a custom PHP application I've written that accesses an API via SOAP, processes some data from the web service, and outputs an HTML table with the results. I'm an experienced WordPress developer ...
0
votes
0answers
21 views

Date format - @ symbol has unexpected behaviour

I created a date format , then added that date format to a field within a view. But the @ symbol is automatically appending to the end of the date format (even though i specified it to go into the ...
0
votes
1answer
16 views

Template hierarchy like Wordpress in Drupal 7+

I am new to Drupal. Is there any template hierarchy structure to output different section of durpla like node, page, vocabulary, block etc. If so how can we use that. E.g. In WordPress we have a ...
0
votes
1answer
26 views

How to add PHP to a node without php filter?

I have a one-off page on my site (webcam), where i need to run some php to eg. calculate today's sunrise time, add a daylight image at night, etc. I understand PHP Filter is a security risk, and not ...
0
votes
1answer
44 views

Fatal error: Cannot redeclare _PEAR_call_destructors() (previously declared in /usr/share/php/PEAR.php:735) [closed]

Fatal error: Cannot redeclare _PEAR_call_destructors() (previously declared in /usr/share/php/PEAR.php:735) in /var/www/quest-cms-dev/sites/all/modules/civicrm/packages/PEAR.php on line 811 ...
0
votes
0answers
9 views

Theme function not working in module with multiple forms

I have following code for my module it has two forms form-example displayPenCard The following code calls the theme function (theme_form_example_form()) and it gets rendered, which is the theme ...
0
votes
1answer
32 views

Should I Unset PHP variables in Drupal?

We all know php's variables(array, integer,string) would be taking large memory. So PHP recommend to unset the variables to optimize the memory. Should I do that in Drupal too ? or Is Drupal ...
2
votes
2answers
17 views

Drupal: How to Access the value of a field of the current node

Within hook_views_query_alter(), I'm trying to access the value of a field of the node currently being displayed. I have added a contextual filter which should give me the nid of the current node. ...
0
votes
0answers
42 views

500 error in a Drupal module: “malformed header from script”

I am debugging an error in a specialized module in Drupal 7; basically, the module receives a HTTP POST request from a remote banking system, and needs to store that data and return an "OK". The ...
0
votes
2answers
15 views

pager is not working when print views

I've created one view with used of php code for some fields in it, and set pager on it too. It's working fine whenever i created given link of view but actually I print that same view on another basic ...
0
votes
1answer
19 views

Assigning global var to session variable?

This must be simple. I want to assign the user name to a SESSION variable, yet this is not working. $_SESSION['loveleytest'] = $user; $_SESSION['thelovelytest2'] = $user->name; What ...
0
votes
0answers
27 views

Incorrect Login Notification Missing using user-login.tpl.php

I've customized my logged in user page using a template file in D7 (user-login.tpl.php). Problem I can't figure out is that if they type in the wrong login/pass, it just reloads the page and there is ...
0
votes
0answers
19 views

problem accessing user variables in rules

I use module rules linkevent https://www.drupal.org/project/rules_linkevent to trigger a rule based on visited path. Tha problem I have that in condition I need to use user variables but get an error ...
1
vote
1answer
26 views

passing argument into markup(renderable array?)

I'm doing the Drupalize.me Drupal 7 module course. We're building a function in an include file that takes and argument from the URL. It then prints the value to the page. Seems simple enough, but ...
0
votes
0answers
10 views

changing default product price programmaticaly if and only if skus match between code and default skus

using http://stackoverflow.com/questions/13491983/drupal-commerce-line-items-alter-the-price/21395149#21395149 by Tim Yao I am able to change default price in cart for all products with same price ...
0
votes
0answers
13 views

empty value inside rules component

I have a simple rule with action calling a component. This action provides one argument value coming from a field (field can have a value or can be empty). Component, among other things, displays a ...
0
votes
0answers
9 views

Drupal file naming convention [duplicate]

I have to extend a Drupal project management project, and since I've only been working with PHP for not too long, I'm not very familiar with PHP naming convention, and practices, such as having an ...
1
vote
1answer
49 views

Display Suite Custom Template Issues

I've been using Display Suite for Drupal 7 (with Bamboo theme,) and I'm trying to build a layout template that contains 5 rows, so I can place the appropriate fields into each row, making all content ...
0
votes
1answer
24 views

Two Blocks for sort filter Views — Drupal 7

I have a view in Drupal 7 with results including a field of date and another with price, I need to sort the results by means of these two fields when I click on the appropriate link (not button or ...
0
votes
1answer
42 views

Using base_url() in image paths without using PHP?

So normally I can do <img src="<?php base_url(); ?>/default/files/image.png" /> and that works just fine if I enable the php filter. The trouble is that enabling the php filter disables ...
0
votes
1answer
25 views

Using PHP 5.2.17 in Acquia Dev Desktop 2

I'm using Acquia Dev Desktop 2 with Drupal 7. On PHP version selection menu, I only see "5.3.29", "5.4.33", "5.5.17". Is it possible to switch PHP version to PHP 5.2.17 since most of my hosting ...
0
votes
1answer
32 views

XHProf not displaying runs but empty table

I'm trying to profile a drupal website using xhprof. I manage to install it and configure drupal to use it (using the devel module) but I have a problem to visualize the result. First, for some ...
2
votes
1answer
42 views

How to hide comment section present in render array?

I have generated an array in Drupal 8 which is created by using viewbuilder in this manner: $content = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())>view($entity, 'hardcopy'); ...
1
vote
2answers
182 views

How to use views replacement patterns while using the PHP filter?

In views, when using the standard text formatter you can place replacement tokens such as [title] into the HTML code either in a rewrite or in this case global text for Drupal to render. In this ...
2
votes
1answer
27 views

Why is my field not showing up in the template?

I created a new field of the type Link for the Basic page content type and the field name is field_secondary_links. All the pages on the site operate based on custom templates and I edited ...
1
vote
2answers
61 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? ...