Work in Progress: Moving Locally

So my cheap webhost is not cutting it for my side project. So I’m now moving it to my local machine since it is 99% for my own usage. The directions on this page for XAMPP are dead simple to follow. You have to do a little mental tweaking since they are a bit outdated, but you’ll quickly see the holes.

Next up, I copied the modules and files (for me, just photos) over to the new location. The images were located in sites/default.

Work in Progress: It’s finally working

So I ran into a lot of trouble on my pet project Drupal site these last few days. I finally managed to solve one of my issues after two days of researching the issue: in order to show a backlinks tab (what references this node) on a particular node, I had to set the path to be /node/%/references. Then in the Arguments (which are now called contextual references in Drupal 7), I had to set it to NID. I will do a write-up later of my View which is using the Entity Reference module to make the connection between nodes.

The Relation module slowed me down for a day and a half. The prospect is promising: instead of just making a vague reference from Node A to Node B (oh, yeah: also in Drupal 7, the different pieces of a website — comments, nodes, etc. — are called entities), you make a new connective entity (a relation) between the two nodes. So now you’d have Node A –> Relation –> Node B. On the relation, you can add other fields. I was thinking that I could turn my relation into a family-like page so I could include stuff like how many children Person A had with Person B. Or if they ever married, if so, where and for how long? I watched several tutorials before finding one that promised if I used the Dummy Relation Widget, I could print out the Relation info + all those extra rich fields on Node A and Node B. Yes! Yes! How exciting!

An hour later I realized that the Dummy Relation widget had been broken and/or the working components had been removed months prior — according to the issues filed. I could make the Relation but when I visited this newly created entity, the “page” was broken. This meant I could not pull the data back out. So, there seems to be a lot of high hopes for this module, but at the current time it is useless.

So, I ended up staying up far too late last night and added the forty or so characters to my website. Did I mention that the point of this website is to be a character database repository — the same thing I was looking for last week? :-)

Work in Progress: Day 2

I added a couple new modules (Conditional Fields and Multiselect) to help with entering data into the website. I then struggled all day with a particular issue that I needed the URL to be only one word but needed to display on the page the entire contents of the field. I created a new tpl.php file and eventually managed to figure out how to print the contents of the field I needed:

but I could not get this code to override the title on the page. This code would only show up in the body. I then tried with the Display Suite model, but no dice. I posted on a few forums online with no luck either. Finally, I decided to create two fields — one for the full length for the title and then another whose single word content I plug into URL aliases. It’s far from an ideal solution, but it was the best that I could come up with.

Work in Progress: New Drupal 7 Website

Evernote’s Clip toolbar thing is not working well, so I decided to document the resources I’m using to build my new website here. The things I am looking to accomplish:

  • Have a node for each article which links to the people mentioned in the article (with backlinks from the person to each article they are mentioned in).
  • Create individual profile pages for each person which will include these fields: Name, Bio, Race, Description, Parents, Siblings, Partners, Children, list of all articles they are mentioned in, and photos.
  • Short story collection which is tagged to the correct person (just like article).
  • Use the diff module to see what changes are made to each node.
  • Wiki-like tools so that hyperlinking to pages is easier. DONE
  • Auto link people’s names to their profile page. DONE with the use of Alinks.

Issues I’ve been investigating:
Backlinking between nodes
Reverse node reference
Creating relationships between people (parent to child, etc.) — this prevents the fields from showing in Views so I cannot manipulate the appearance of fields. It’s cool how you can show ancestors and decedents, but there is no way to show siblings. I also need to be able to customize relationship types since the ones present were too restricting.

Issues with setting up Drupal 7:
1&1 issue that I had to fix with a bit of code to the .htacess
1&1 issue with Clean URLs
Posted for help in figuring out if I can choose which content type a freelink goes to.

Modules installed:
Alink
Automatic Nodetitle
Backup and Migrate
Ctools
Diff
Entity Reference
Entity API
Freelinking
Pathauto
Talk
Token
Views
Wikitools

Resources:

To create automatic node titles so that only the first word shows as the title (which will make linking in Alinks super easy since you only need to enter the first name of the person):
First, download Automatic Nodetitles and enable it.
Second, in your selected content type, create the field which will be replacing the title field. In my example, it is called xyz9990 so I enter that in the bold section of code.
Then on your content type, select Automatically generate the title and hide the title field and then enter the below code:


field_xyz9990[$node->language][0]['value'];

$text = strip_tags($text);
$words = str_word_count($text, 2);
$pos = array_keys($words);
if (count($words) > $limit) {
$text = substr( $text, 0, $pos[$limit]);
$text = trim( $text );
$text = rtrim( $text, '.' );
}

return $text;
?>

Make sure to check off the Evaluate PHP in pattern box.

Theme Ideas:
Twitter Bootstrap for Drupal

Things to consider:
What will the Conversation title field be? — Make sure to change it back since it is currently the sample Automatic Nodetitle example from above.
When configuring the freelinking module, you need to make sure to specify the relative path.
A wiki might not be what I’m after since they’re wanting to create other wiki pages instead of linking to other node types.
To create a revision, you need to check off on the revision tab in your node to make a node that you’re making a revision. This is not auto like in WordPress.

Create Profile Page with Related Nodes in Views – Part One

A request that came in from the Library staff was for an archival view showing all posts related to a speaker. In the current setup, you can only find the posts by doing a general search on the website. What I wanted to create were these content types and have them show up on the same page together: speaker, events, and videos. To make these content types work in Drupal 6 similar to what I have you will need to have these modules installed: CCK, Node Reference URL Widget, Node Reference, Imagefield, ImageAPI (I use the ImageAPI GD2 in the modules list), ImageCache (I use the ImageAPI GD2), Views, and Views attach. Make sure to give yourself permissions for each module and configure the Imagecache to create the proper image sizes for your needs. I created thumbnail, small, medium, and large based upon the sizes we were using in a Javascript function already. I am also using Display Suite, Node Display, and Views Display to make theming easy. Make sure to set up your URL aliases and custom breadcrumbs as well per content type!

If a field within a section (e.g. Basic settings) is not mentioned here, leave it at the default).
The content types:

Speaker

  • Change default title and body to Name and Biography.
  • Add the field Photo with a type of File. Configure as needed.

Event

  • Add the fields Speaker with a Node Reference to speaker (This excellent video from Mustardseed Media will explain how to do it!).
  • Add another Photo field.

Video

  • Add the fields Speaker with a Node Reference to speaker.
  • Add a second Node Reference to the Event field (note: I am having trouble getting the video link to show up on the Event field).

Create the Views:
Make a node View. You will now make several displays. Remember that after making the Default display, on any other display, you will need to Override everything. So I will go through each of the displays with their fields.

Defaults
Basic Settings
Title: Speaker Profile (will show up to the users).
Link display: Speaker Individual Page

Relationships
Content: Speaker (Label: Page Reference)

Arguments
Node: Nid
Action to take if argument is not present: Hide view/Page not found (404)

Fields
Node: Title
Content: Photo (Generic files with a Widget Label of Photo — probably not a good thing to set here, but this is my setup)

Sort criteria
Node: title (asc)

Filters
Node: Published (yes)
Node: Type = Speaker


Speaker Individual Page — Page Display
Basic Settings
Name: Speaker Individual Page (for my usage on the backend so I can see which display is which)
Title: Speaker Profile (will show up to the users).
Items to display: 1

Page settings
Path: ____ (set whatever URL you want. Mine is set to events/speakers/% with the percent sign representing an individual speaker. Use the % !!!).

Relationships
Content: Speaker (Label: Page Reference)

Arguments
Node: Nid (Action to take if argument is not present: Hide view/Page not found (404))

Fields
Node: Title
Content: Photo (large image)
Node: Body (remove label)

Sort criteria
Node: title (asc)

Filters
Node: Published (yes)
Node: Type = Speaker


All Speakers — Page Display
Basic Settings
Name: All Speakers
Title: Speaker Profiles (will show up to the users).
Style: Grid
Items to display: 20
Use pager: Yes

Page settings
Path: ____ (set whatever URL you want).

Fields
Node: Nid (Label: Nid; Exclude from display)
Node: Title (Remove label; Output this field as a link: events/speakers/[nid] — make sure Node: Nid is on top of the Fields so the Nid will pull successfully into here).
Content: Photo (thumbnail image)

Sort criteria
Node: title (asc)

Filters
Node: Published (yes)
Node: Type = Speaker


Video Attachment — Node content Display
Basic Settings
Name: Video Attachment
Title: Speaker Profile (will show up to the users).
Link display: Speaker Individual page

Node content settings
Node types: Event, Speaker
Arguments: nid (Use the ID of the node the view is attached to)

Relationships
Content: Speaker (Label: Page Reference)

Arguments
Relationship:
Node: Nid (Relationship: Speaker)

Fields
Node: Title (Link this field to its node)

Sort criteria
Node: title (asc)

Filters
Node: Published (yes)
Node: Type = Video


Event Attachment — Node content Display
Basic Settings
Name: Event Attachment
Title: Speaker Profile (will show up to the users).
Link display: Speaker Individual page

Node content settings
Node types: Speaker
Arguments: nid (Use the ID of the node the view is attached to)

Relationships
Content: Speaker (Label: Page Reference)

Arguments
Relationship:
Node: Nid (Relationship: Speaker; Action to take if argument is not found: Hide view/Page not found (404))

Fields
Node: Title (Link this field to its node)

Sort criteria
Node: title (asc)

Filters
Node: Published (yes)
Node: Type = Event


Work in Progress — This is to create a single event page which calls in the Biography (formerly called body) field of the Speaker content type. This way the person creating an event will not have to rewrite the bio every time a speaker visits.

Event Single Page — Page Display
Basic settings
Name: Event Single Page
Title: Speaker Profile
Row style: Display suite fields
Items to display: 1

Page settings
Path: _____ (enter whatever URL that you wish)

Relationships
Content: Speaker (Require this relationship)

Arguments
Node: Nid

Fields
Node: Title (Label: Title)
Content: Photo (Label: none; medium image)
Node: Body (Label: none)
Node: Body (Relationship: Page Ref)

Sort criteria
Node: Title (asc)

Filters
Node: Published (yes)
Node: Type = Event

Next time we will look at how I am setting up Display Suite to show these different node types.

Bulk Export Nodes in Drupal

I had a colleague request a copy of blog posts she had written. I had been given this task while in graduate school for a class but had been unable to withdrawal the records at that time. Here is how to do it in Drupal 6 with Views 6.x-2.12 and Views Bonus Pack (enable Bonus: Views Export). I used this as a guide for correctly setting up the export.

Create a new node View and then create a page display.
My settings for each area is broken up by area:

Basic Settings
Name: Export nodes
Style: DOC file (for my needs)
Items to display: ____ (insert the number you need)

Feed Settings
Path: _____ (enter your URL here — this is what I choose but you could change Link Display under Basic Settings from Page to Export nodes. Maybe. I’m not sure)

Fields
Node: Title
Node: Post date
Node: Body

Sort criteria
Node: Post date (asc)

Filters
Node: Type (choose whichever content types apply)
User: Name (Operator: Is one of and Usernames: _____ [whoever’s nodes you are exporting])

When I saved and went to the URL I had specified as the path, the Word Doc immediately downloaded. The formatting looks weird as it is in three columns thanks to the fields and the pictures did not download.

Exhausted

I haven’t updated in a few days because I’m so exhausted. Tonight at least I’ve been working with Panels on abandoned Drupal 6 website I started a couple years ago. Now if I could get it to work at my job… I’ve began to discover some of the possibilities, but I’m also a little confused how panels would work/be used by non-admins. I’m assuming that you would use the node template in Panels to design your node layouts and then let Panels take care of the layout when a new node is added by a user.

The creator of Panels also expressed a belief that additional build modes could be added to Panels via Display Suite but so far I have found nothing to support that theory. Correction: cannot be done in Drupal 6. :-(

Friday Holiday

I was sick Thursday and then had a short day on Friday since I had to burn off some over time. Before work I went out and picked out a new set of eyeglasses (I picked them up after work and not even three minutes later, my old pair snapped in two — great timing!). My main tasks then:

  • Emails about consolidating two library accounts into one. I made the decision to not consolidate.
  • Worked in the computer labs for an hour.
  • Discussed website, UX, and Drupal child themes with my UX colleague.
  • Copied some Bootstrap CSS into the test site’s CSS and made three buttons.
  • Met with a coworker to discuss the four page site she needs for One Book One Community.
  • Tried to create a Drupal child theme but failed when the tpl files and regions were not showing up.

When I came home I worked on answering my WordPress students’ questions and checking them off the assignment sheet. Over the weekend, I worked on Code Year, tried to use genealogy software to keep track of characters (quickly found lots of flaws such as in gay couples, each is assigned a traditional spousal role — husband or wife — even though the program acknowledges the person’s sex), read, watched some BBC programming, and tried out Pinterest.

How to Hide Empty Fields in Drupal with PHP

The content type I am working with does not require an image. However, if there is no image, the border of the image box still prints. I found the solution to hide an empty field here in comment #9. In essence, you pinpoint the CCK fields that you want to hide if they are empty. Then you add this line directly above:

< ? php if(!empty($node->field_address[0][‘value’])){?>

then directly below type this:

< ? php } ?>

Note: Make sure to remove the spaces between < and PHP and ?.

Event Registration Using Wufoo and Drupal and Google Docs

  • Used only one content type (called Class).
  • Added information about the individual class in multiple CCK fields (stuff like title, date, instructor, description).
  • Made an additional CCK field called “Form_Embed” to place the code from Wufoo.
  • Made the first form in Wufoo with the bare minimum of information required from the patron (name, email, library barcode, member status). I duplicated this form for each class that required registration. Then for each class, I changed the title, how many people class, and set the length of the registration period. Each class has a confirmation message thanking them for registering and the patron will receive an email that states the same message as the confirmation screen.
  • I copied the Wufoo iframe embed code into the “Form_Embed” field for each Class content type. The form is currently closed but you can see it here until 01/16/2012.
  • Then to address the issue of patrons who still want to go on a wait list even after the class closes (Wufoo will automatically close the class when it reaches the selected number of submissions). The wait list is listed on a special menu and is a Google Form. I made sure to make it clear in the Confirmation message that we will only email those accepted.
  • Next I created a Google Form so people can add themselves to sign up to be notified of future classes. Later this will need to go into a mailing list through Contactology.