Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[META] Convert listings to Views #151

Open
6 of 14 tasks
quicksketch opened this issue Jan 5, 2014 · 7 comments
Open
6 of 14 tasks

[META] Convert listings to Views #151

quicksketch opened this issue Jan 5, 2014 · 7 comments

Comments

@quicksketch
Copy link
Member

quicksketch commented Jan 5, 2014

We should convert the core listings into views. Converting the following lists to views requires:

  1. Click together an identical view in Backdrop.
  2. Add it's config file to the appropriate module.
  3. Provide an upgrade path for those D7 sites that were using the non-view alternative.

Conversions

Pages:

Blocks:

Administrative pages:

Other things:

Upgrade paths

Providing an upgrade path is not necessarily a novice task, but the code examples below should get you close. Please note, the code below has not been tested and is here for reference purposes only :)

  1. Write an update hook for the appropriate module in it's .install file.

  2. Assemble the data needed for the view.

  • read in the values of the config file for the view
  • json_decode so you get a PHP array
  • var dump the contents of the PHP array
  • copy/paste this array and hard code it as $data.
// Remove below this line after the array is generated.
$file = file_get_contents('path/to/views.view.whatever.json');
$view = json_decode($file);
print backdrop_var_export($view);
// Remove above this line after the array is generated.
$data = array(
  'hardcoded' => 'stuff goes here',
);
  1. Check the associated variable settings for the view (if there are any)
  • if there aren't any, or if they aren't set, do nothing.
  • if they are set, update the appropriate parts of the $data array.
  • if the display is a block, also check if the block was in use. If so, make sure the enabled part of $data is set to TRUE.
  1. Save the view to config.
// Save the view as config.
$config = config('views.view.'. $machine_name);
$config->setData($data);
$config->save();
  1. delete associated variables, if any exist.
update_variable_del('whatever');

Related

Relevant issues needed for some conversions:

Relevant Drupal.org issue: [Meta] Convert core listings to Views

@ghost
Copy link

ghost commented Oct 4, 2014

In creating all these default views for entities in Backdrop, should we decide on a standard naming system for both the administrative view name and the machine name? Also, should these all be separate views, or should views for the same entity types be combined? E.g. make the "Who's new" block a block display on the 'admin/people' view (which would be a page display)...

@quicksketch
Copy link
Member Author

Should we decide on a standard naming system for both the administrative view name and the machine name?

If we're shooting for consistency, perhaps we try [module_name]_[block_delta] for blocks and [module_name]_[admin_path] for paths? That might end up with long, awkward view names for admin paths like user_admin_people, where I might prefer user_admin_listing or even just user_admin. I'd say let's just start with prefixing the views by the module that ships them, then go from there.

As for displays vs. separate views, these should definitely be separate views. Displays within a single view can be difficult to locate, especially if there are multiple page or block displays on the same view. The overall admin-listing isn't capable of displaying multiple paths at the same time, so finding the right view is hindered when they are combined. In addition, the "overridden" vs. "default" experience is still really difficult for new and experienced users alike, which we should avoid in our out-of-box views.

@tarekdj
Copy link
Member

tarekdj commented Jan 10, 2015

@quicksketch it's better to use var_export($view); the output is cleaner than var_dump().

@tarekdj
Copy link
Member

tarekdj commented Jan 10, 2015

@quicksketch I think it's update_variable_del() not variable_del() ?

@quicksketch
Copy link
Member Author

@quicksketch it's better to use var_export($view); the output is cleaner than var_dump().

Thanks! And actually we should use backdrop_var_export, as that will format the export according to our own coding standards. Updated the docs.

@quicksketch I think it's update_variable_del() not variable_del() ?

Also correct. Updated.

@quicksketch
Copy link
Member Author

Marked #1101 duplicate of this one.

@klonos
Copy link
Member

klonos commented Oct 13, 2019

The fact that the "Who's new" and "Who's online" blocks are missing has been brought up on Gitter today. Perhaps we should consider shipping core with a view that includes those 2 blocks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants