Hello.

I was wondering all the time, why displays should be named only as "page_N", "block_N" or something like that. I thought that it was some limitation caused by this, but it's not, as display IDs are storing as varchar(64).

So, I made a patch which makes this possible. It also adds primary key to views_display table on (vid, id) fields for better storage.

Comments

seaji’s picture

Subscribing

wom’s picture

Subscribing

andypost’s picture

Status: Active » Needs work

Looks like a great feature, D7 already have script-generated machine-readable key for nodes, and taxonomy so views display could be named same way.

@neochief As I see you add a primary key. What is a purpose of it? Please comment this on code

+++ views.install	1 Oct 2009 22:04:11 -0000
@@ -286,6 +287,7 @@
 /**
  * Add aggregate function to PostgreSQL so GROUP BY can be used to force only
  * one result to be returned for each item.
+ * Add the primary key to views_display table.
  */
 function views_update_6007() {
   $ret = array();
@@ -294,5 +296,6 @@
@@ -294,5 +296,6 @@
     $ret[] = update_sql("DROP AGGREGATE IF EXISTS first(anyelement)");
     $ret[] = update_sql("CREATE AGGREGATE first(sfunc = first, basetype = anyelement, stype = anyelement);");
   }
+  db_add_primary_key($ret, 'views_display', array('vid', 'id'));
   return $ret;
 }

This should go into into new hook_update_N()

I'm on crack. Are you, too?

neochief’s picture

Status: Needs work » Needs review
StatusFileSize
new4.25 KB

It safes you from adding duplicate displays_id/vid pairs (yes, patch contains validation too, but just in case primary key should be present too). I'm not sure about positive effect on performance, but at least it should not decrease it.

Moved update to another update function.

a.a.egoroff’s picture

Subscribing

neochief’s picture

Bumping this up. Can anybody review the latest patch please?

andypost’s picture

I have no views 6.3 installed so please provide 6.2 patch against drupal-6-2

neochief’s picture

Actually, it's almost the same, try to apply it and I bet you'll succeed.

merlinofchaos’s picture

+        'value' => $this->display->new_id ? check_plain($this->display->new_id) : check_plain($this->display->id),

I think this will generate a notice.

+            '#value' => t("<strong>Important!</strong> You have changed display's machine name. To see suggestings for it, you need to save the view."),

Typo here =)

I don't see any changes to view.inc -- how does new_id get actually stored to the database?

neochief’s picture

Do we need to save new_id? I guess no, as it's temporary. Earl, take a look at changes in includes/admin.inc. Display id is being replaced there just before view is saved.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to 3.x branch!

neochief’s picture

Thanks!

Status: Fixed » Closed (fixed)

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