Questions tagged [external-scripts]

Use it for question about calling Drupal functions or methods from an external PHP script.

Filter by
Sorted by
Tagged with
14
votes
5answers
7k views

Bootstrap from external script

I am trying to create Drupal entity instances from an external script that is not part of Drupal or a Drupal module. For Drupal 7 there was drupal_bootstrap to load the required Drupal dependencies. ...
0
votes
0answers
68 views

Programmatically add a node

Some years ago I made a Drupal 7 site. I want to remake the site with Drupal 9. In Drupal 7 I added nodes programmatically with this PHP code. define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT ...
0
votes
1answer
825 views

How do I use the login for an external application?

Long ago I built a php based application for room reservations which basically ran on its own – outside the website's CMS. It was part of what I would now call a custom made intranet – or "custom-app"....
-1
votes
1answer
65 views

Query user_field_data in Drupal

I need to query the user_field_data table to see if a user exists. Through a query string, I pass to a php script that is on the server username and password in clear text. This script connects to the ...
0
votes
1answer
101 views

“Fatal error: Call to a member function setFormClass()”

I am trying to load the node in an external script, and shows me the following error. Fatal error: Call to a member function setFormClass() in field_ui_entity_type_build() The code causing the error ...
0
votes
0answers
24 views

Why do I get an error about loading the htmlpurifier/library/HTMLPurifier.auto.php file?

I am creating files to be run in different situation using scheduled cron jobs. These are mainly for either cleaning nodes, updating or doing other calculations automatically. The drupal site is ...
0
votes
1answer
69 views

Programmatically log in a user

I am trying to authenticate users as below. I don't get any error, but it doesn't log in users. autoLogin.php is located in the root folder. Visiting http://example.com/drupal8/autoLogin.php shows me ...
0
votes
1answer
74 views

How do I log in a user?

I want to log in Drupal 8 users from an external PHP file. I am trying the following code. use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; use Drupal\user\UserInterface; //$...
0
votes
0answers
40 views

Add image using cURL

I'm migrating data from Zoho creator into Drupal 7. I wrote a PHP script to get all records and save them into nodes and that worked fine, but I need help to get the images and add them to the nodes ...
0
votes
0answers
39 views

How do I use a core class from an external script? [duplicate]

I am trying to access a node programmatically and getting errors though using (AFAIK) the recommended way. My code (so far) is really simple. use Drupal\node\Entity\Node; $nid=1805; $node = Node::...
0
votes
1answer
28 views

Allow authorization via cookies

We are migrating from Drupal 7 to Drupal 8 and are currently at the last hurdle - relying on Drupal's session to authenticate for custom scripts. Previously we used to rely on drupal_bootstrap but now ...
1
vote
1answer
162 views

How can I bootstrap a multi-site instance?

It's possible to bootstrap Drupal 8 and create a new node using answer # 174474. define('DRUPAL_DIR', '/usr/share/nginx/html'); use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\...
0
votes
2answers
72 views

Is there a cli equivalent of the web ui with underspecification?

background I run drush cget markdown.settings and see: dependencies: module: - markdown parser: id: michelf/php-markdown-extra render_strategy: type: none settings: ...
1
vote
0answers
75 views

Checking if user logged-in by external script, fails

With a script on an external webpage (same domain), I need to detect whether the user that's visiting the page is or not logged in. [EDIT] This occurs when the script is into a subfolder. If it's put ...
2
votes
1answer
38 views

How can I check to see differences across my multisites?

Currently, we're using Acquia Content Hub to syndicate content across our sites with a spoke and wheel syndication architecture. We essentially use a single site (that content editors use to create/...
0
votes
1answer
34 views

Is it possible for 3rd Party Script to Create Users [closed]

Our company has many systems that require for users to have user names and passwords. We have been able to use SAML to cut down on the number of accounts we must manually create. With that said, we ...
0
votes
2answers
5k views

How do I access the database from a stand-alone PHP script?

I have problems to define the right path to the root and bootstrap data in php. My structure (Windows) looks like the following. C:\xmapp\ htdocs\ testdrupal\ test.php includes\ bootstrap.inc ...
0
votes
1answer
108 views

How do I render the main navigation menu?

In Drupal 7, we were able to render the main navigation menu onto a page outside the main Drupal folders by including bootstrap.inc and displaying it with this code. $menuData = menu_tree_output(...
2
votes
1answer
1k views

How do I check the current user session?

In Drupal 7, I was able to use bootstrap.inc in an external PHP script, which was a custom set of pages that simply bootstrapped Drupal to check the user was logged in Drupal. The following code is a ...
0
votes
1answer
217 views

How can I bootstrap?

How can I bootstrap Drupal 8 from an external script? This an example script from the RabbitMQ Work Queues tutorial. require_once __DIR__ . '/vendor/autoload.php'; use PhpAmqpLib\Connection\...
2
votes
0answers
45 views

Sharing data in the same database, being able to edit data

I am looking for a way for Drupal to be able to access and modify data in an external table in the same database. Both Drupal and the script need access to the same data. Duplicating/Migrating is ...
0
votes
1answer
141 views

Accessing variable_get when loading bootstrap from an external file

I am loading the core drupal 7 components through an external file by loading bootstrap. While the core drupal functions work properly, when I try to access variable_get I keep getting the default ...
0
votes
0answers
199 views

Running a PHP script with Elysia CRON

I want to automatically run a PHP script every 3 hours or so. The script is pretty heavy. It pulls XML data from another website then encodes it into a JSON file to be imported by feeds. The ...
2
votes
2answers
587 views

Load node entity from external script with image URI

I'm attempting to grab a node from a node ID in an external php script. With Drupal 7 I used the bootstrap.inc but with Drupal 8 this are a bit different. I've called Drupal with: define('...
3
votes
1answer
3k views

how to include external php file in drupal 8 [closed]

I want to merge two xlsx file and download merged file in drupal 8. So i used a PHPExcel library for doing so. But i am not able to include a PHPExcel.php file in custom controller for that. I used ...
1
vote
0answers
45 views

Posting Data to an external site using APIs

I've been tasked with posting information from our website to recreation.gov, using their API http://usda.github.io/RIDB/ Is there a specific way using any sort of drupal module or built in PHP with ...
0
votes
1answer
39 views

PHP filtered page is cached

With a few years of Drupal 6 and 7 experience, I've happily made my first Drupal 8 installation. In my previous installations of Drupal I've used custom made PHP code that does a lookup in a personal ...
-1
votes
2answers
3k views

How do you get DRUPAL_ROOT when using it in a separate php file?

It has been covered many many times on several sites, explaining how to define DRUPAL_ROOT and bootstrap the page (whatever that actually means). However no one has ever said how to use it in a ...
-1
votes
1answer
390 views

How to insert PHP code into the Drupal 7 block with PHPFilter to enable a html form working?

<form action="run_pipeline.php" method="post"> Insert SRA identifier <input type="text" name="email"><br> <input type="submit" value="Run data processing pipeline"> </form&...
2
votes
1answer
41 views

How to mass copy the title of each node to a taxonomy term?

I need to copy the title of nodes to its taxonomy term. I have the following content type Title - text Body - text Taxonomy term - (currently empty) I want to copy the "Title" ---> "Taxonomy term" ...
2
votes
1answer
31 views

how to tell which book node is the root node programatically [closed]

If I have some nodes that are of type book, how can I go through them in a php script and tell which is the root? thanks
0
votes
3answers
336 views

How do I access the Drupal class from a standalone PHP file?

How do I use the \Drupal class in an standalone PHP file?
2
votes
1answer
1k views

What is the best (secure) way to run PHP code on a Drupal 8 system?

I am pretty new with Drupal. I have installed Drupal 8.17 on my webserver and now I am configuring it. It runs on Ubuntu 16.04 with Apache 2.4 and PHP-7.0, the DBMS is PostgreSQL 9.5. I would like ...
0
votes
2answers
38 views

Kill border by using PHP?

In my theme on Drupal 7:50 there is #banner just beneath #menu. For #banner I have made {border-bottom:5px solid blue} The problem is that sometimes #banner is empty and then the #border remains and ...
-2
votes
1answer
62 views

Creation of a Content Type to Meet Required Use Case

How do I achieve the following Use Case? Use Case Example Widgets, Inc. offers franchising opportunities. They have 3 different franchising levels (bronze, silver and gold). Widgets, Inc. needs to ...
2
votes
0answers
319 views

External script fails to load all drivers

Attempting to create an external script that allows me to query some things in Drupal. I was hoping to be able to use my external databases I have defined in the settings of my site to query some of ...
0
votes
1answer
41 views

Running Drupal API Scripts offline

I want to run some maintenance scripts against a Drupal 7 system. These scripts will call the Drupal API to use things like EntityFieldQuery, node->save and so on. I could create a module called ...
1
vote
1answer
210 views

Is it possible to have an external script run index.php that bootstraps Drupal?

It seems like such a simple question, and I apologize for my Drupal ignorance, but I am unable to get our Drupal contractors to accomplish what seems to be a simple request. I need the below script ...
0
votes
2answers
101 views

Is a MySQL statement from an external script possible?

I'm working with a PM on a Drupal project, and we're having little success finding a developer to answer (what we believe to be) a simple question. I'm afraid I have no Drupal experience to speak of. ...
2
votes
2answers
1k views

How to store a single array value into a session variable? [closed]

I have Array ( [0] => cid [1] => TN201501HP ) Now I want to store "TN201501HP" into some session variable. How to store this value to a session variable?
1
vote
2answers
648 views

How to generate content to Drupal 7 with a PHP-script?

I have been given the task to generate a couple of thousand of pages in drupal that should contain text generated by a php-script. After that is done, I'm supposed to perform searches on the generated ...
2
votes
0answers
124 views

Returning the userId from an external script

I have a very simple external php script which will not return the userId. The script is posted below: <?php include_once "/includes/bootstrap.inc"; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); global ...
1
vote
1answer
105 views

Access to other custom php pages

I am new to Drupal, so please bare with me. I have a Drupal site that is working fine. Now what I want to do is allow access to folder which contains some custom php script. I tried to put the ...
1
vote
2answers
644 views

Getting “Fatal error: Class not found” by bootstrapping external script and executing user_save function

I have a problem i've struggled with for a long time, and it's starting to really piss me off, so i hope you can help me. The thing is i'm writing a custom script (not a module) that needs access to ...
-2
votes
1answer
156 views

Is this way safe to bootstrap Drupal from an external PHP script? [duplicate]

I want to bootstrap Drupal from an external PHP file located in Drupal's root directory. The following code will do the job. error_reporting(E_ALL); ini_set("display_errors", 1); define('DRUPAL_ROOT',...
0
votes
1answer
37 views

Multilanguage Website

I'm trying to run some script from Pinterest, to validate my site. What's happenning is I need to write in Pinterest the url of my site, but my site redirects always like this : "XXX.com/es". How can ...
0
votes
0answers
29 views

Webform mail sending is successful but message says otherwise [duplicate]

I have this webform for contact. The site uses phpmailer 7.x-3.x-dev and library 5.2.9. When the webform is submitted, I get the error : Unable to send e-mail. Contact the site administrator if ...
0
votes
0answers
42 views

Prevent image uploads with embedded code

I have a site which allows anonymous users to create a node with an image (the site allows people to submit images with quote memes so that the authenticity of the quote can be verified, quotefail.com)...
0
votes
1answer
1k views

How to include an external PHP script?

I have PHP file and I need to include that PHP file in static page. Where is best place to store that PHP file so I can include it in a static page.
0
votes
1answer
122 views

Placing a drupal menu on an external site

I have a drupal install (latest 7.x version at the time of writing). It is in the root directory of my domain. In a non drupal sub-directory, called 'member' so at /member, I have 3rd party script ...