Wednesday, June 1, 2022

How to configure CORS in Drupal 9

 To grant access from 3rd party sites to your site resources let's say your Restful services , You need to configure it first, Otherwise as a security concern, Browser itself deny the request.


How to enable access from myjsapp.com to Drupal 8/9 site.

Goto sites/default folder

Copy the default.services.yml file, and place in the same folder and rename it services.yml

Now find the cors.config section, it looks like this as default. 

Change enabled to true, Set allowed headers to 'x-csrf-token', 'content-type', 'accept' etc.,

Change the allowedOrigins from [*] to your authorized applications. ex: http://myreactapp.local:8000 

# Configure Cross-Site HTTP requests (CORS).
# Read https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
# for more information about the topic in general.
# Note: By default the configuration is disabled.
cors.config:
enabled: false
# Specify allowed headers, like 'x-allowed-header'.
allowedHeaders: []
# Specify allowed request methods, specify ['*'] to allow all possible ones.
allowedMethods: []
# Configure requests allowed from specific origins.
allowedOrigins: ['*']
# Sets the Access-Control-Expose-Headers header.
exposedHeaders: false
# Sets the Access-Control-Max-Age header.
maxAge: false
# Sets the Access-Control-Allow-Credentials header.
supportsCredentials: false

Wednesday, May 4, 2022

How to generate a link which adds product to the cart in Wordpress

In Wordpress, We can have links to add product to the cart which is required sometimes especially when sending campaign links to promote product or course and providing buy product option.

Ex:  https://www.yourwpdomain.com/?add-to-cart=3016&quantity=1

    Will add product with id 25 to the cart with qty 1

    https://www.yourwpdomain.com/?add-to-cart=3016&quantity=3

Tuesday, March 7, 2017

Headless Drupal

Drupal is the world’s popular and widely used CMS framework. Drupal back-end system is very strong and can be used for managing any type of content like text, categories, media, geospatial, etc. 

The term Headless Drupal means, use Drupal as a backend system and Rest server, so that content operations (read, update, delete) can be done from another language or tool. Drupal 8 comes with Rest Server included in its core. In Drupal 7 we can achieve this with a contributed module called Services or RestWS.

Nowadays people are using many devices like desktops, laptops, mobiles, tablets to explore the content and in parallel front-end frameworks are also invented to provide a better user experience while viewing content among different devices.

Since most people are using smartphones these days, many businesses want to stay with people always by providing their services through mobile apps and attract people with some offers and ads.

Using Headless Drupal content-rich back-end system can be done very quickly and data can be exposed through REST API. The front-end can be done by using any of the desired front-end frameworks like Angular JS, Backbone, or any other similar framework. We can also use the same REST API for developing mobile applications.


This way we can build different kinds of applications like a single page (SPA), responsive, mobile apps, etc. with a single Drupal back-end system.

Tuesday, February 7, 2017

Drupal 8 Multisite Creation

Goto /d8codebase/sites/sites.php file.

Add below array
$sites = array(
 'site1.com' => 'site1', // Domain name => Folder name.
 'site2.com' => 'site2',
);

Then create site1, site2 folders inside /d8codebase/sites/ folder

Like in D7, Inside site1 and site2 folders create separate settings.php and add the database and other configurations specific the site.

Add site1.com and site2.com in vhosts file.

Friday, May 29, 2015

Solution for Slow queries issue in Drupal 6

If you are running drupal 6 application with multi lingual setup especially using i18n module, Then there might be having mysql  database issues like slow queries means some queries might take more than 30 minutes to execute and in turn shuts down the mysql server.

If anyone experiencing the same issue, then apply below patch to fix the issue.

https://www.drupal.org/files/issues/337089-26.patch

Refer.
https://www.drupal.org/node/337089#comment-4482720



Tuesday, April 14, 2015

Best Bulletin Board (Discussion Forum Software)



I am glad to share the information that, I have used many forum softwares so far and found Mybb is the best among all with very decent features.

Some of the most useful features are


  • Private Messaging : Send and Receive private messages
  • Calendars and Events : Manage multiple calendars and conduct events
  • Email notifications : When new thread opened, send automatic email notification to all users who subscribed to the forum 
  • Reputation : Give ratings and comments to the user posts
  • User Promotions: Promote users based on post count, reputation score
  • Warning System : Warn and punish users when they act inappropriately
  • Mark as best answer : Like stack overflow, Choose the answer as correct from user replies, this feature doesn't exists in core, but we need to install and configure mysupport plugin. 
  • Mass email and newsletters: Send mass emails to the registered users
  • Task scheduling system: Keep your forum always in good shape by running Scheduled tasks behind the scenes 


Have a look at all features
http://www.mybb.com/features/

Friday, April 10, 2015

Reasons to love Drupal8

Drupal is world's leading open source content management system. Drupal8 is the latest release on it's  journey. Already beta version got released with modern object oriented programming approach.
Below are the list of significant features added in the Drupal8 core.
Mobile in its DNA : Deploy content once and watch it in any device the way you want.
New Configuration Management: Manage configurations across different environments with ease
Better user experience: Serve your visitors with better experience by using Jquery autocomplete and modal dialogs.
Effortless Authoring: With WYSIWYG editor and in place editing, content authors can manage content very easily.
Views, out of the box: Many new features in views
Better markup with HTML5: The page markup in drupal8 is now html5-based.
Multilingual Capabilities: Translate any string in the system with built in interface.
Built in web services:  Build mobile apps with drupal8 as your data source.
Fun and Fast Theming: Build sites quickly with flexible and secure twig template engine. 
Field Power: Drupal8 provides more field types in core like email, phone etc..
Easier migration process from earlier version
So this will be the major release in drupal history with big change in it's architecture. Many useful Symfony (PHP based open source MVC framework) components are included in the drupal8 core and also included some third party PHP components and finally created a world class content management system.

Tuesday, December 17, 2013

Drush Installation from Pear Channel

Below is the easy way of installing drush in linux systems/servers.

#Add drush channel to pear list
pear channel-discover pear.drush.org

#Check whether is it added or not
pear remote-list -c drush

#Then run install command as below
pear install drush/drush
pear install drush/package_name (or version_name)

Now enjoy running Drush commands straight away without any further configuration :)






Monday, May 9, 2011

My skype icon didn't visible

In ubuntu sometimes, the skype icon hide from panel, when you select the option remove from panel, then the solution is:

right click on an empty area in your notification area (top-right bar by the clock) and select "Add to Panel" now scroll down and find "Notification area" then OK.

you should be able to see the green >>running<< skype instance along with all non running duplicates. Right click and close the duplicates.
You can now close the main skype window with the "X" and bring it to the foreground again with the green notifier.

Wednesday, April 6, 2011

Enable clean urls in Ubuntu


  1. Ensure that mod_rewrite is enabled for Apache 2:
     % sudo a2enmod rewrite
  2. Edit Apache 2 configuration to allow Drupal's .htaccess file to be used. In file /etc/apache2/sites-enabled/000-default, inside the tag Directory /var/www/, replace the line
    AllowOverride none
    with
    AllowOverride All
  3. Restart Apache 2:
    % sudo /etc/init.d/apache2 restart

Tuesday, April 5, 2011

Drush installation and configuration steps


Drush configuration steps

1. Download Drush module from http://drupal.org/project/drush and place drush folder into your home directory. E.g: '/home/drush/'

2. In command line, execute following this statement.

PATH="/home/venkat/drush:$PATH" for temporary

3. Add this line PATH=/home/drush:"${PATH}"  in  /home/venkat/.bashrc file

4. Execute following command in command line

$ . .bashrc (including .dots)

Some Drush commands
1. drush cache-clear
2. drush sql-conf
3. drush sql-cli
4. drush dl cck zen
5. drush enable cck , drush pm-enable quiz
6. drush disable cck, drush pm-disable quiz

Here you can find more drush commands http://drush.ws/

Monday, January 10, 2011

Drupal 7 Release Party @ Hyderabad - Sponsored by Azri





This release party was celebrated by Drupal Hyderabad team and sponsored by Azri soultions

see more photos at At my facebook album

Thursday, January 6, 2011

Sunday, January 2, 2011

How to send images as email content but not as an attachment.

Below is the process to send image as email content.

1. Open the image in internet explorer or google chrome browser or any other browser. Dont open in firefox. Also your image need to be in any live website (ex: flickr or photobucket etc..) coz you can't send from your computer.

2. Then right click on the image and select the option copy or copy_image

3. Then paste in your mail body. Thats it.

Monday, December 20, 2010

Where should find the trash files in ubuntu

The deleted files can be found in the hidden directory ~/.local/share/Trash

Thursday, September 9, 2010

Set ubuntu screen resolution

http://techblissonline.com/ubuntu-804-set-default-resolution-1024-768-virtual-pc-2007/

Friday, September 3, 2010

Problem with [[!CDATA ]]

Sometimes when you load the xml file, you didn't get the data between the tags [[!CDATA ]]. This is the character data and you can't get with simplexml_load_file library. In that case use that function as below, so that it will escape the CDATA from url.
$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA)

Friday, August 27, 2010

Drupal Custom Module Structure

The module should place at sites/all/modules/custom

Ex: mymodule
-mymodule.info //contain module meta data
-mymodule.module //contain actual logic
-mymodule.js
images (folder)

mymodule.module

Thursday, August 19, 2010

Send mails from your domain

Your hosting provided need to create one mail server for your domain then only mails sent from your domain name like from : mail@mysite.com, otherwise some default mail server details displayed in mails header information.

To check is mail server set for your domain then run below commands at dos prompt.

ping smtp.mysite.com
and/or
ping mail.mysite.com