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

0
votes
0answers
23 views

Problem getting Drupal SESSION value from standalone php page in subdirectory

Last 2 days I am searching for solution on Internet. I have a module in my drupal site's "sites/all/modules" folder named "coupon".I added a new test.php file in the "coupon" folder which has no ...
0
votes
1answer
13 views

Creating a dynamic URL in node--resource.tpl.php

I'm trying to create a URL in my node--resource.tpl.php file that contains fields from the resource in question in the URL. The following code is what I've been playing with, but when the user clicks ...
0
votes
0answers
8 views

Using substr() with Drupal search-result.tpl.php returning fewer characters than expected

In my search-result.tpl.php file I want to return only the first 200 characters of the body field before outputting it to the screen (assuming there are that many characters). I'm trying to use the ...
0
votes
1answer
15 views

Using Left() with Drupal Custom Module

I'm trying to return only the first 200 characters (if there are more than that) from a body field in a Drupal custom module. I've found the general php/mysql solution here: ...
2
votes
1answer
8 views

Drupal 7 Comments Alternating Row Colors

I'm interested in making the comments that appear on my resource content type nodes show with alternating background colors. Anyone know how to make this happen? I tried something like this with CSS ...
0
votes
0answers
49 views

Trying to theme my user login/registration/password reset pages in Drupal 7, going bonkers

What seems like it should be a very, very simple task -- theming the user login, registration, and password pages in Drupal 7 -- is turning out to be a Kafka-esque nightmare. I can't figure out what ...
0
votes
0answers
21 views

To use some hook instead of “PHP contextual filter code” in view

Can anyone please give a solution on having a substitution of "PHP contextual filter code" for views, inside a module code?
0
votes
3answers
29 views

Redirect user based on role and node content

I want to redirect a user when they login based on what role they have and whether they have created a node of a type. So if the user has administrator role, direct user to admin url else if the ...
0
votes
1answer
28 views

How to load a field from a user that is being viewed

I am looking to load a field from a user's profile that is being viewed.For example, I am looking at another users profile and it will load their associated field. I am programmatically adding a ...
1
vote
2answers
86 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 ...
0
votes
2answers
27 views

How do I get the user name of the user profile page that is being visited.

I created a module and I need to use the user name of the user's profile being viewed, how do I call/get it?
0
votes
0answers
12 views

display suite code - set token value of color field module as php variable an convert to rgb

$hex = "[node:field-ref-participants-category:field_color]"; print $hex; list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x"); echo "rgba($r,$g,$b,.9)"; Why does $hex printed correctly, but doenst work ...
0
votes
0answers
13 views

PHP code & panels; how to transfer database code into module code [duplicate]

There are various blog posts on how to get php code in views out. See https://ohthehugemanatee.org/blog/2013/12/26/44497-people-are-wrong-how-to-never-use-views-php/ ...
0
votes
0answers
13 views

PHP code is not working on Drupal Rule translation

I am working on a multilingual site and using i18n module for language translation. Now I am trying to translate a Rule containing <?php?> code. But <?php?> code is not working for Rule ...
0
votes
2answers
20 views

Coloring rows in returned drupal search results

I'm trying to modify search-result.tpl.php and template.php to color the backgrounds of search results returned such that every row has a different color than the one that preceded it. Only two colors ...
0
votes
0answers
17 views

Custom rules not working in an entity form

I have created an entity form with two integer data type text fields named Enter first number and enter second number. I save the entity form as greater of two. In the entityform > rules, I add a ...
2
votes
1answer
27 views

+1 user field after comment is made

I created a new user field to keep count of comments. I want to increase it by 1 after a user posts a comment and decrease it by 1 when comment is deleted. Is there any way I can use rules to do ...
0
votes
0answers
14 views

Drupal taxonomy-term text-body dependency

i'm using drupal for a website where i post from time to time different events. For this, i made a taxonomy type with four vocabularies, each stands for another event type. Now my question: I know ...
1
vote
3answers
23 views

Multiselect values not getting saved in hook_settings()?

This is the code I have implemented in my module which is working fine! /* * This is a helper() */ function MYMODULE_feeds($page_id = '') { foreach($pagefeed['data'] as $feedval) { ...
0
votes
1answer
75 views

Making Panel-Col-last the first

I have a 2-column panel (Regular, not stacked). I've made it responsive and it appears allright in mobile view @media screen and (max-width: 519px) {width: 100%;}. The only problem is that my site ...
0
votes
0answers
9 views

Preprocess function values not persisting

I am having a really bizarre problem over the last few days. I'm trying to alter a field value through a preprocess function and while I can see the value has been changed inside the function, it ...
-3
votes
2answers
40 views

Is there a way of converting a Drupal project into pure and optimized PHP-MySql code?

I have a project in Drupal 7 whose development has finished. We will not add more new types of content, no more custom or contributed modules, only data. As Drupal is based in PHP: is there a way of ...
0
votes
2answers
16 views

Adding Placeholders for PHP variables

When creating a query using db_query in my module I want to make sure it's as secure as possible. So I'd like to use placeholders in my 'WHERE' clauses. The problem I'm having is how to use ...
0
votes
1answer
41 views

Run a Drupal website offline (±without server)? — E.g. hand it over on a usb-stick / by mail? — Run it from the HD, while retaining functionality?

Why run Drupal offline? Since I use free webhosting, I don't have 100% up-time, so I started wondering whether I could maintain such Drupal functionality, while at the same time working offline. An ...
0
votes
2answers
35 views

Malicious Code - Website Disable

I'm new to Drupal. My website has been disable due to malicious code found in /var/www/vhosts/domain.com/httpdocs/sites/all/themes/tao/tao/css.php What should I remove in this file? ...
0
votes
2answers
28 views

Computed field that displays the full username of the author

I am using a computed field and I want to display the field_first_name and field_last_name, which are properties of the user that created that node. I have been trying things, but it seems like ...
0
votes
1answer
17 views

Simpletest fatal error without message

locally my unit tests run just fine. On my online dev server, they fail and I don't get any error message despite "The test did not complete due to a fatal error." in the test messages and "An ...
0
votes
1answer
39 views

Views PHP: Global(PHP) value for end date

I am rewriting the output a view block with a Global(PHP) field from the module Views PHP, and one of the fields I am rewriting is a Date field. The value for the field is : 2015 - 08:30 to 09:30 I ...
0
votes
1answer
23 views

Problems with SQL Syntax using Left Join and OR

I need some help with my SQL. I've got the following code but it's returning multiples of each item and I don't understand why. When I only include the first Left join it returns results as ...
-1
votes
1answer
33 views

advance search to show post by date

i trying to make the search on drupal show result by date. for example if i type 25/05/2010 it should return posts for that date and also search by key work which is default on the search. how can i ...
0
votes
0answers
7 views

Problems with a “filter field options on term refernce” ajax callback

I'm having problems with a "filter shops on section" ajax callback, when field_sections (term reference with unlimited values) changes field_shops (entity reference) should show all shops with the ...
0
votes
1answer
36 views

Views check access by PHP

I've got 2 roles on my system -uzman and isveren- and several views that need to be restricted to either uzman or isveren. For that purpose, I have been trying to check access control with PHP. I ...
0
votes
1answer
53 views

Displaying Database Data Within the Flow the Site

I have a multi-page form that works fine in and of itself (pathfindertool.module). However, once a user clicks submit I want the page to display some records on the page. And it DOES display the ...
0
votes
2answers
46 views

Printing block on all pages of a contenttype

In my page--front.tpl.php i have a menu block rendered using: <?php $block = block_load('menu', 'menu-basic-menu'); print render(_block_get_renderable_array(_block_render_blocks(array($block)))); ...
0
votes
0answers
21 views

New site, user 1 does not login

I've recently reformatted my machine, and I've just noticed a really weird issue when I'm setting up new Drupal sites. When creating a new site (either through Drush or just downloading manually) you ...
0
votes
2answers
31 views

How to remove user role using hook_user_update

I am having trouble trying to remove a role after user account submit. I have used the following code: function vdb_form_alter(&$form, $form_state, $form_id) { global $user; } ...
0
votes
0answers
7 views

display non published comments with special test and condition

How can i modify in the loop of displaying the comments in drupal 7 foreach (....) { if ($comment->stauts == 0 && $comment->condition ==1){ // Display comment with new class } } ...
0
votes
0answers
13 views

Change a menu link for translation in D7

I have tried the solution as below : function taxonomylocalize_menu_link_alter(&$link) { if ($link['link_path'] == 'node/249' && $link['module'] == 'menu') { ...
1
vote
0answers
61 views

How to get product attributes (weight, dimension.height..) in php

I am fairly new to drupal commerce and php so pardon the dumb newbie question. I downloaded commerce_order_ftp_export and after updating it to the devel version I was able to get it working. It ftps ...
-3
votes
1answer
41 views

How to check author role in Views PHP

I need to check author role using views php. I've already added a relationship and added a field(excluded from view) User: role. How can I check if author role is equal to 'administrator'?
2
votes
1answer
60 views

Possible to set user privileges on part of the text?

In my node I have embeded a view using php snippet in body field. When regular user edits it I don't want him to accidently delete the snippet, is there a way to hide or lock that part of the text ...
0
votes
0answers
78 views

Render webform submissions in template

I want to render webform submitted data below the form on every page from a specific content-type. But not all fields are allowed for everyone to see like a phone number, views could solve that but ...
0
votes
0answers
28 views

Add css or prefix/suffix created form.

I am creating a dynamic form in drupal. It needs to create a question for each row in a mysql table. The mysql questions will be changed on a daily basis. My issue is formatting each question into a ...
1
vote
2answers
20 views

Display a link to create new content when content missing (via Contextual Filters)?

I'd like to give users the option to create new content when a certain contextual filter is missing on a panel. e.g. I have my reviews on a panel. When a review is missing I'd like it to display a ...
0
votes
0answers
24 views

why does trying to add a line item on order presave redirect to the user page?

I have a lot more code than this in the hook_commerce_order_presave() however this if ($show_charge_in_cart == True) { $product = commerce_product_load_by_sku("0909990000005"); $line_item = ...
-1
votes
2answers
43 views

How to insert HTML that includes an ampersand>

I've created a custom block, and I'm trying to get this custom block to output a specific piece of HTML. The HTML needs to be different on every page, because it needs to include the page's URL in it. ...
0
votes
1answer
56 views

Changing textfield into textarea

I hope I'm right here with my request and someone can help. I'm working on a website with Drupal, but am not a trained programmer. I use a module which allows me to display a tooltip in Drupal. By ...
0
votes
2answers
37 views

Code review - Reading a field collection

I am trying to read a field collection and build an array in PHP. The array I want to build goes like this:(it's in JS notation but you can easily imagine the equivalent in PHP) highlights = [ ...
1
vote
0answers
39 views

PECL uploadprogress bar does appears But doesnt move

I installed the PECL uploadprogress bar in php and this is working fine but when I start uploading a file it ends up getting stuck and dissapearing when the file is uploaded. This is what i see when ...
1
vote
1answer
47 views

How to patch file-field.inc/file.css webforms file upload progress bar [closed]

I installed the PECL uploadprogress bar for my webforms module in drupal 7. This is installed fine but when i try to actually show the uploadprogress bar it just doesnt show up but puts a empty body ...