Stream

Join this community to post or comment

Chris Weber
owner

Share Knowledge  - 
 
 
Working with PHPUnit and PhpStorm. Learn more in the blogpost by Gary Hockin http://ow.ly/gZHA30857WL
Here's the answer. Firstly, Adam talks about having templates you can use to generate the boilerplate code around your test quickly. PhpStorm already does this when you create a unit test, either from the “Navigate to Tests” action or if you use “New” in the project manager and select PHPUnit then ...
1
Add a comment...

Scott Sawyer

General Discussion  - 
 
Drupal 8 module development question:

I am creating a Bit.ly module to shorten URLs. I want to expose a "function" to allow other modules to use my module ( pass in a URL to be shortened with the Bit.ly API ).

I think I want to create a "service" that other modules can use. Is this the correct methodolog? Do I need a service container?

I am trying to find a good example of that sort of workflow. I am looking at these two tuts: https://lakshminp.com/writing-your-first-drupal-service, http://www.titancloudworks.com/captains_log/post/drupal-services-at-your-service

What I am not seeing in these tutorials:
1 - How another module would call my service and pass in an argument ( the URL to be shortened in my case. ( $bitly_url = \Drupal::service('bitly.shorten')>getBily($url); maybe?)
2 - How, once I get that argument, I can process it with my module. ( I don't think I want all of my api called in the service controller )

Another topic I haven't really gotten to, but it will come up, if another module doesn't want to depend on my module, but would like to use it if it's available, how would I go about doing that? Right now I have something like this:

$moduleHandler = \Drupal::service('module_handler');
if ($moduleHandler>moduleExists('bitly')) {
// do something
}

Is that really a good way to manage "optional" modules?
Get the most out of your social and online marketing efforts. Own, understand and activate your best audience through the power of the link with Bitly Enterprise.
1
Nia Kathoni's profile photoScott Sawyer's profile photo
26 comments
 
Well, I got it working, the dependency injection that is. Took forever to get. In one of my module in the construct I had:
$this->bitly = $bitlyShorten;
It worked fine in that module, but the other module only worked when I changed it to:
$this->bitlyShorten = $bitlyShorten;
The log said bitly was undefined. Not sure why changing it mattered. 
Add a comment...

Scott Sawyer

General Discussion  - 
 
Has anyone used the Key module? https://www.drupal.org/project/key

Specifically, have you used it in a D8 project? I'd like to store API keys with it, but I haven't seen any good documentation. The info in the README is pretty sparse. 
Key provides the ability to manage keys, which can be employed by other modules. It gives site administrators the ability to define how and where keys are stored, which allows the option of a high level of security and allows sites to meet regulatory or compliance requirements. Examples of the types of keys that could be managed with Key are:
1
Alexei Rayu's profile photoScott Sawyer's profile photo
4 comments
 
Yeah, so any third party API key. Specifically I want to store bitly keys. But on any given site, you have any number of private API keys. Storing in the database doesn't seem like a good idea, and storing in config seems worse.
Add a comment...

David Mesa

General Discussion  - 
 
Hello guys! I forgot how to configure clean urls... mod_rewrite in appache is good, but I don't remember if I need to change something in .httacces file, cause it dosnet't work... I readed .httacces file and remove # in one line but it still without work. Thakns for your help
1
David Mesa's profile photoScott Sawyer's profile photo
6 comments
 
Glad to hear you got it worked out. Sometimes it's the most basic things and it's just easier to start over.
Add a comment...

Scott Sawyer

General Discussion  - 
 
I am trying to develop a module and have some technical debt ( I don't know what I'm doing ). I want to use an external PHP library, the library is on packagist. I created a composer.json, required the package, ran composer update and the package was added to /vender.

Not I want to write my module which will use this library ( package ). The package documentation says to require the /vender/package/autoloader.php, but that doesn't seem like the correct way ( or Drupal way ) to use it. Maybe I'm wrong.

What is the recommended way to use the library in my module?
1
Scott Sawyer's profile photo
7 comments
 
I just wanted to post back and let you know that your help was extremely useful. I am able to use the library in my module.
Add a comment...

Phil Ward
moderator

General Discussion  - 
 
Panels has always been my go-to module when it comes to building custom pages in Drupal 7. Now in Drupal 8 things have changed. A lot of what Panels did in Drupal 7 has been moved over to Page Manager. Panels itself doesn't offer a user interface and it is just a variant type in Drupal 8. Also, Page ...
3
Scott Sawyer's profile photoPhil Ward's profile photo
2 comments
 
Not off hand :-/ I've pretty much only ever used panels as well.
Add a comment...

Matt Glaman

General Discussion  - 
 
 
In March I get the honor to keynote DrupalCamp London! This will be my first keynote, my first time in London, and my second time to Europe. I'll also be talking about Drupal Commerce 2 in a separate session.

Come check out DrupalCamp London and say Hi
Danese Cooper. Danese Cooper currently serves as chairperson of the Node.js Foundation. She also works in an open source role at PayPal. Previously she was Director of the Open Source Hardware Association and CTO of the Wikimedia Foundation. She had brief stint at the Bill & Melinda Gates ...
1
Phil Ward's profile photoMatt Glaman's profile photo
2 comments
 
+Phil Ward thanks!
Add a comment...

Jonah Brown

General Discussion  - 
 
This is soo cool to read. Nice to see how the Drupal community works together to make a platform even better. Lots of goodies on the horizion.

https://www.drupal.org/blog/moving-the-drupal-8-workflow-initiative-along
Nine months ago I wrote about the importance of improving Drupal's content workflow capabilities and how we set out to include a common base layer of workflow-related functionality in Drupal 8 core.
4
Add a comment...

Jesus Manuel Olivas

General Discussion  - 
 

Another day another release, #DrupalConsole RC-14 is out.

Contributed commands can be discovered from `{module_name}/console.services .yml` to avoid issues with #Drupal8

1
Chris Weber's profile photo
 
Oh wow, that's a rapid pace
Add a comment...

Jonah Brown

Share Knowledge  - 
 
I just published a long 16min tutorial/ walkthrough on Custom Search with Search API and Views - Drupal 8

I did make an amateur mistake in my approach and left it in the video. I do correct myself and it became a great learning moment.

Seriously this module is amazing!

https://sweethoneycode.com/drupal-tutorials/custom-search-with-search-api-and-views-drupal-8/
There is an incredible module for Drupal 8 that allows you to make a custom search engine. It is called the Search API module, it is very extensible. I will show you how to add this to your site and get it setup. I will only be covering a basic setup. There is so much more …
8
Add a comment...

About this community

Welcome to the Drupal Community on Google+! Please use the links provided below to connect to the Drupal community, find help, and help others. *Drupal Community Events:* _Core Mentoring:_ Tuesdays at 02:00 UTC Wednesdays at 16:00 UTC _Windsprints:_ Fridays at 13:00 UTC Search this community: #drupal #php #community
Worldwide

Chris Weber
owner

Share Knowledge  - 
 
 
This one is dedicated to all my fellow Drupalers. There’s no better exercise for a brain than reading ancient chinese poetry taming Drupal 8. When I’m bored, I turn to ...
1
Add a comment...

Phil Ward
moderator

General Discussion  - 
 
Drupal 8.3 is still a few months away, coming April 5, 2017, but there are already some changes we can look at, most notably in the experimental modules. In December, 2 new experimental modules were added to core, and BigPipe was officially changed from a beta module to stable. The 2 new modules you’ll find in 8.3 are Workflows and Layout. Let’s take a peek at what these are all about.
4
2
Add a comment...

Chris Weber
owner

Share Knowledge  - 
 
 
January 13, 2017. One project I'm working on needed a Behat test added to test whether a particular redirection works properly. Basically, I wanted to test for the following: An anonymous user accesses a file at a URL like http://www.example.com/pictures/test.jpg; The anonymous user is redirected to the ...
2
Add a comment...

Chris Weber
owner

Share Knowledge  - 
 
This series looks really good but I don't see any mention to the excellent config split module. I suppose since it's third party and not stock Drupal it doesn't get the nod. But +Brian Lewis is there still time to include it?
Drupal 8: Composer and Configuration Management. I'm releasing a new series today!!!!! Over the last year, I've given a talk at DrupalCon, DrupalCorn Camp, and Drupal Camp Colorado all about using Composer and Configuration Management in Drupal 8. Those sessions were around 45 minutes, ...
8
2
Brian Lewis's profile photoChris Weber's profile photo
6 comments
 
Yea config_split has a similar exclusion list but it also has a grey list. I don't know what it's for though
Add a comment...

Phil Ward
moderator

General Discussion  - 
 
Drupal 8 Contact Forms

Curious what the opinion is on the new D8 contact forms. While it's nice to be able to customize them, through my limited amount of messing with them, I find them to be utterly useless. YAML forms seem to be the much more widely needed route for forms, so it begs the question of when core will implement a better form system?

Anyone have any luck with the new contact forms or are you ignoring them in favor of a better implementation?
1
Scott Sawyer's profile photoPhil Ward's profile photo
13 comments
 
+Scott Sawyer​​ yeah, that's a good point. My thought though is to start with an entity and define the bundle type.

"Create entity"
What kind of entity?
"Page entity" (node)

It would proceed to create an entity with options to add additional fields such as title, body, URL, author, etc.

I hate that blocks are global. There are times when I need pieces of content added to a specific page, but it isn't global (site wide) content. Blocks don't make sense for that. There are times when I need pages (nodes) that don't need front facing URLs. There are times when I need taxonomy lists, but they don't need to be publicly accessible through a term list page.

Much of the current core functionality, you're stuck with and have to somehow manually disable. "If" Drupal we're more of an entity builder (call entities whatever you want) then a person could create an entity bundle that acts just like a node, but doesn't need the author field, or maybe even the URL field. I feel like Drupal has evolved into this awesome "do anything" platform as long as you stick to the archaic rules of using Drupal's old ways of doing things.

"Drupal has entities! You can create and form your own entities and bundles to your liking! As long as you know how to code...". While ECK does step in to help with this, many of the core fields aren't actual fields but rather hard coded in such a way that you still can't truly customize the platform without a bunch of hacked up code to work around it. A skill many (like myself) don't have the luxury of.

My vision isn't to do away with the core items, but rather set them up as "entity profiles" that are provided by core. Everything starts with creating an entity and the profile would define a node, or block. (If you want or need them). Otherwise, you could create a custom entity from scratch to create the exact same things with different names.
Add a comment...

Chris Weber
owner

Share Knowledge  - 
 
Great guide on how to quickly insert taxonomy terms to a previously created Vocabulary. This might be something that is needed for every project.
From time to time, I've needed to have a default set of Taxonomy terms created at the same time as a content type, as in the case of a field with a required Taxonomy term reference, using a Taxonomy that is not 'free tag' style. Instead of requiring someone to go in and manually add all the terms after ...
1
Add a comment...

Bhavin Joshi

Share Knowledge  - 
 
This #Drupal CodeLet allows you set password using #Rules: http://bit.ly/2c3RnB9
1
Add a comment...

HR Joshi

Share Knowledge  - 
 
#Drupal Tip: Remove N/A option from radio button list options: http://bit.ly/2iJMgIr 
2
Add a comment...

Mahnaz afsharpour

General Discussion  - 
 
how can Organic group Admin enter score for each member in one list?
Hello Happy new year.
I developed schodmanagment system with Drupal.I defined "course" as a organic group content type.
each course envolve students.I want the organic group admin be able to view the students list, and he/she can enter score for each student via list.
Help me How could I define score?
Thank you.
1
Mahnaz afsharpour's profile photoScott Sawyer's profile photo
3 comments
 
+Mahnaz afsharpour​ this is not a trivial problem, there are many steps so I can't give you a step by step process to do it. I can give you a high-level strategy, but you will have to go through the process of learning how these tools work ( if you are not already familiar with them ) and solving the unique detail of your specific problem.

Since you did not answer any of the questions in my post, I am going to assume my assumptions and assertions are correct, and you want to do it my way.

These are the key modules you would need:
Paragraphs
Entity Reference
Entity Reference View Widget
Rules
VBO

There will likely be other modules that you would need.

/admin/structure/paragraphs

Build a paragragh.
2 fields:
- Score. Likely a text field or number field
- Student. Likely you want an entity reference to user, not the profile2. It can make you life a little easier, and you can always get the profile2 properties from the user.

I just realized, you want your entity reference to only list the OG members. This makes things more complex. You now need another module "entity reference view widget", I added to the list. I am not going to go into details for that module, only to say you need to create an entity reference view that is a list of OG members, likely using the contextual filter of NID from the course.

On your "course" content tyoe, add the paragragh field.

Now you need a new view of the course. It would be a table, first column would be the student ( OG member ), second would be the score field. You will need to build the relationship to the paragragh entity reference in views.

Actually, I just thought of a better approach, add a Paragragh to the student's profile2. It would be an entity reference to their courses.

The basic things still apply. This is a complicated problem, to be sure.

What you want to end up with is a table view where a teacher (I assume) will have a list of their students, showing the score ( showing zero if there is no other score ) in one column.

Here comes Rules. This is going to be tricky, and if you've never used rules, you will need to read a lot and try many settings.

You need to create a rules component. You need a component the has an Action ( either a Rule Set or Action ). It need to accept 3 parameters, a user ( student ), a node ( course ), and a string ( score ).

Actually building this is very complex, I don't know that the VBO can provide 2 values from the view object. You might either have to write a custom hook to provide it automatically or have the teacher enter either the NID ( course ) or UID ( student ).

What you want rules to then do is load the user, add a Paragragh reference to the user's profile that includes the course, and populate the score with the teacher provided value.

Then in you OG Member view, you need to add a Bulk Operation field. This part is easy.

For someone very familiar with these modules it could take a few hours to a few days depending on what problems they encounter, how well user input is handled.

I use Rules and VBO in a lot of custom management dashboards. It gives the site manager a familiar paradigm, and it's very powerful.

Add a comment...

Jesus Manuel Olivas

General Discussion  - 
 
The #DrupalConsole RC-13 is out.

API break for contributed commands introduced. Instructions how to fix at the blog post #Drupal8.

https://drupalconsole.com/articles/drupal-console-rc-13-out

1
1
Add a comment...