If a user enters a 'Page Title' value, and then they decide they no longer need it and want to go back to the node generated one - it doesn't work by clearing the 'Page Title', the only work around that I have been using is just setting the title to the same thing as the node title.

Comments

finkenmann’s picture

Same problem here. Once i've typed something in, it's not possible to delete it later. I had to clear it in the page_title database table.

hctom’s picture

subscribing... same problem here

Rickdrummer’s picture

subscribe

giorgosk’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

please test

akalata’s picture

Code changes are successful, but patch had to be applied from Drupal's webroot rather than the module's folder. I'm not sure what the best practices are for that.

giorgosk’s picture

Status: Needs review » Reviewed & tested by the community

so lets set this to RTBC

tmedlen’s picture

Patch worked for me, had no problem patching from module directory either.

SamH’s picture

Assigned: Jenya » Unassigned
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.13 KB

I tested Giorgos's patch, and it works correctly. I'm reuploading the patch with correct pathing.

ttjordan81’s picture

Status: Needs review » Reviewed & tested by the community

It works for me.... RTBC....

ttjordan81’s picture

It works for me.... RTBC....

jaime@gingerrobot.com’s picture

It works for me too. Thankyou.

Energyblazar’s picture

how do i use this patch in a live site ?

SamH’s picture

@Energyblazar,

Make sure to try this in a development environment before you do anything on a live site :)

To apply the patch:
Making and applying Drupal patches with git
Applying patches with git

If you are not using git, this command will also work:
patch -p1 < patch-file-name.patch

Let me know if that doesn't make sense.

nicholasthompson’s picture

Status: Reviewed & tested by the community » Needs work

I'm rejecting the patch because it results in an empty row in the DB.

We need it to remove the row if empty, otherwise we could end up with thousands of no-value rows in the DB which is simply wasteful and inefficient.

Good catch on the bug though, working on it now.

nicholasthompson’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Status: Needs work » Fixed

Fixed in dev with the following:


[nthompson@localhost page_title]$ git diff
diff --git a/page_title.module b/page_title.module
index 5d7367e..25c4086 100644
--- a/page_title.module
+++ b/page_title.module
@@ -402,8 +402,15 @@ function page_title_node_insert($node) {
  * Implement hook_node_update().
  */
 function page_title_node_update($node) {
-  if (user_access('set page title') && isset($node->page_title) && drupal_strlen(trim($node->page_title)) > 0) {
-    db_merge('page_title')->key(array('type' => 'node', 'id' => $node->nid))->fields(array('page_title' => $node->page_title))->execute();
+  if (user_access('set page title') && isset($node->page_title)) {
+    // If there is content to the Page Title, 'merge' it (ie, either UPDATE or INSERT)
+    if (drupal_strlen(trim($node->page_title)) > 0) {
+      db_merge('page_title')->key(array('type' => 'node', 'id' => $node->nid))->fields(array('page_title' => $node->page_title))->execute();
+    }
+    // Otherwise, delete the row (if there is one)
+    else {
+      db_delete('page_title')->condition('type', 'node')->condition('id', $node->nid)->execute();
+    }
   }
 }

Basically, if the "length > 0" then we do an UPDATE/INSERT SQL otherwise we just do a DELETE.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.