Category Archives: Drupal

How use Tower with GitLab

So Academic Computing setup an instance of GitLab for version control, so I’m moving some things from both SVN and Github. We’re using Tower as a GUI, and it took me a bit to figure it out. But yesterday I did. ๐Ÿ™‚

  1. Make sure you have an account on git.evergreen.edu!
  2. Make sure you have an SSH key on your local machine set up in GitLab. Open Terminal and type in cat ~/.ssh/github_rsa.pub — if there’s stuff there, copy it including “ssh-rsa” and go all the way to the email at the end. Then open git.evergreen.edu, go to your profile, then go to SSH keys. The title should be something identifying your machine, and the code should be the code. Note that this assumes you have an SSH key from using github. So, yeah.
  3. Create an empty project on gitlab. (If you’re migrating an up-to-date repo on Github, there’s a setting for that. I haven’t used it yet, because I’ve been having issues updating my Github theme repo.) Copy the URL (I’ve been using the HTTPS URL, but SSH might work too?).
  4. Go into Tower, click on the Clone button, and enter the URL. Your username is your full evergreen.edu email. Follow the directions.
  5. What I’ve then done so far is copy the files from my old theme repository into the folder for my new repository. There’s probably some way better way to handle it.

And now you have a repository on gitlab and your local machine!

Context vs Views for site navigation

Originally I was going to use Context to set all the section navigation. But this last week worth of doing automagical things with Views and Taxonomy has got me thinking that maybe even the navigation can be set via a View. And the pages that show up as navigation options, that list in the term’s field can also be set by a View.

(Show all nodes with term X as options to pick in the navigation, basically.)

VIEWS ALL THE THINGS.

(And then it’ll be easy for whomever on our team to create all the basic settings for a site section, all in one place.)

Ditto with site title

Originally, I was including the Site Section name via Field as Block (which is pretty cool!), but it links to the taxonomy term, which is definitely not what I want.

So I added to the view I described in my previous post, with another block including the taxonomy term name, and an entity (node) set as a field in the term.

The tricky bit with this is getting the link right, and I may not have it down perfectly yet.

For the Section Home Page field in the view, I chose Entity ID for the formatter, but also had to make sure to Remove whitespace (under Rewrite Results) to get the NID correctly for turning into a URL in a Custom text field.

Tricksy background image thing

So on our current site, each section has a “background” image; it’s an actual img tag, but it looks background-y.

I’m using Taxonomy to set the site sections, incorporated with Workbench Access. Generally speaking, we don’t want our editors to update this image themselves. (boy howdy no.) So the image is a field on the Taxonomy itself.

To get the right image on the right sections, I’m using a View to tie things together.

  1. The view is a block of content with fields.
  2. To display the actual image, you have to set up a Relationship to the correct taxonomy vocabulary. Then add the image field to the view and delete the Title or any other fields.
  3. To display the right image, you also have to add a Contextual Filter, Content Nid with the default value of Content from URL.

Then it just works. ๐Ÿ™‚

Media + CKEditor

  1. Install & enable Media (1.4 works fine) and CKEditor.
  2. Configure CKEditor:
    1. Go into each profile that should have access.
    2. Go to Editor Appearance.
    3. Make sure “Plugin for inserting images from Drupal media module” is checked.
    4. Remove the Image button from the current toolbar.
    5. Add the Media button to the current toolbar. (It looks like the Image button, but as if the little pictures were stacked!)
    6. Go to Advanced Content Filter.
    7. Add “img[*]” (w/out quotes) to the Extra allowed content box. (Probably you could narrow down the attributes in the brackets, but I’m just going with * for the time being.)

Then: ta-da! It just works. (Assuming that your site has been set up with permissions for uploading via Media module, which is a whole other story.)