Use Share Embed Functionality Without Header

Created on 16 October 2015, over 9 years ago
Updated 9 June 2025, 23 days ago

First Off, thanks for the great module, I needed something like this for a project, and this saved me a bunch of time writing one myself.

Problem/Motivation

I am using this module mostly for the embed feature, I do not require the share link, as I don't want visitors to actually share my view, I just need to embed the view on another website.

This plugin requires you to add a header to your view, which is obviously visible to visitors when the view is displayed. I can hide the header using CSS (which I did in some cases), but I would love to be able to remove the header from the view at the code level, so there is no output.

I went ahead and tried this, removing the header from my view, and constructing my own URL to the view embed. This worked very well, with one minor notice appearing:

Notice: Trying to get property of non-object in views_share_embed() (line 347 of /var/www/xxx/xxx/xx/sites/all/modules/views_share/views_share.module).

The notice is caused by:

$plugin = _views_share_find_plugin($view);

This function attempts to find the views_share_handler_area_share plugin and returns NULL if it does not find it.

The notice arises, because the following lines assume the function above always returns a plugin:

$plugin = _views_share_find_plugin($view);
  drupal_add_js(array('viewsShareEmbed' => array(
    'rewriteLinks' => $plugin->options['rewrite_links'],
  )), 'setting'); 

However, as noted above, _views_share_find_plugin can return NULL.

Proposed resolution

Short of reworking the entire module to allow for embeds without the header being generated at all, I'll provide a patch that checks the value of $plugin in the above lines, and defaults to NOT re-writing the links, as we can't assume one way or the other.

I also suggest we log a message to watchdog indicating the issue, so site builders have a clue something that is going on.

Remaining tasks

  • Review patch for inclusion.
  • Potentially allow view embed link generation without the requirement to add a header to the view.
πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States skadu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024