Is it possible to link to a View (page display)?

Comments

anrikun’s picture

This will be added in next version :-)

knalstaaf’s picture

Fantastic! Thank you.

joostvdl’s picture

What is the timeframe for this?

anrikun’s picture

I'm busy at the moment so I guess I'll be doing it in March.

joostvdl’s picture

Will this also come available in D7 version?

anrikun’s picture

Yes, the 2 branches are kept in sync.

pbeakley’s picture

subscribe

sheathe’s picture

subscribe

mcfilms’s picture

I'd like to request that you don't limit it to just Views? Many modules produce pages. For example the module "site map" (http://drupal.org/project/site_map) creates a page at domain.com/sitemap. It would be nice to create a relative link to that page from CKeditor.

anrikun’s picture

New 6.x-2.x is out in dev.
It allows to add links to menu items: so linking to views is possible when the views have menu items.
I will not work on any direct "link to view" feature myself, so developers who want to work on it or extend CKEditor Link in any other way (using the new hooks) should read #1107954: New 6.x-2.x and 7.x-2.x: To developers who want to support CKEditor Link.

knalstaaf’s picture

Great feature! Thanks, Henri!

anrikun’s picture

Version: 6.x-1.2 » 6.x-2.x-dev
designcontext’s picture

How does this work? I have views in menues but can get a internal link for them. The title of the view is not found in the autocomplete widget and when I use the path I got an error message because of the use of slashes I suppose. How can I link a view in CK Editor???

anrikun’s picture

This feature in only in 6.x-2.x-dev for the moment and is not documented yet.
Navigate to admin/settings/ckeditor_link and select the menus to be available as autocomplete suggestions. The menu item linking to your view should show up in suggestions then.

amanire’s picture

First off, I really like the improvements to the administrative interface and that fact that I can choose which menu items to reference. Great work so far! Unfortunately, I am getting a message that says "Link must be a valid internal path." after selecting a view. I'm using the WYSIWYG module. Is there another undocumented step in the configuration?

anrikun’s picture

Please copy and paste your path here.

amanire’s picture

StatusFileSize
new94.46 KB

Well, in this particular case, I've created a view with a page display that has a menu item in the Primary links menu. The view URL path is "about/client-stories". I also tried creating link independently from the view in the menu UI but that didn't work either. See the attached screenshot.

Update: I experience the same warning message with dead simple URL paths, too, e.g. "news".

I should also mention that this is a development site using D6.20 and Views 6.x-2.12.

anrikun’s picture

Are you sure that you use 6.x-2.x-dev?
The Link Type is no longer "Drupal" in 6.x-2.x but "Internal path" and your screenshot shows "Drupal".
If you do, please try to clear your browser cache.

amanire’s picture

Ah, nevermind, I found the problem. Long story short, the older plugin.js file was still in my module directory. Thanks, this module is great!

anrikun’s picture

Please replace *all* your ckeditor_link folder by the latest 6.x-2.x-dev :-)

amanire’s picture

Hmm.. but now, my Unlink button always appears grayed out. :'-(

This appears to be a conflict because the Unlink button works again when I disable the CKEditor Link module. Should I post this as a separate issue?

anrikun’s picture

CKEditor has absolutely no control on the Unlink button so it is not a conflict.

Are you sure you updated correctly? Remove your current ckeditor_link folder and download the latest 6.x-2.x-dev.
Also make sure you use the latest CKEditor module and editor.
Once you updated, clear your browser and your Drupal cache.

By the way, the Unlink button is always greyed out when no link is selected. It is only active once you select an existing link.

amanire’s picture

I re-downloaded the CKEditor library and upgraded the WYSIWYG module and the Unlink button is back. Thanks a ton, anrikun!

peteruithoven’s picture

Great work on the module.
Is there any progress on putting this in the D7 version?

anrikun’s picture

@peteruithoven: everything that is in 6.x-2.x is in 7.x-2.x too.

BalfNl’s picture

I've created a small custom module to add a link to views which basically just contains 2 files:

the module file ( in this case ckeditor_link_views ) with the following function:

<?
function ckeditor_link_views_ckeditor_link_types() {
  return array(
    'views',
    array('type' => 'views', 'file' => 'includes/ckeditor_link_views.inc'),
  );
}
?>

and in the mentioned included file:

<?php
/**
 * Implementation of hook_ckeditor_link_TYPE_autocomplete().
 */
function ckeditor_link_views_ckeditor_link_views_autocomplete($string) {
  $matches = array();

 
  $views = views_get_enabled_views();
  
  foreach( $views as $view ) {
		if($view->display['page'] != null) {
			$matches[ $view->display['page']->display_options['path'] ] = $view->human_name;
		}
  }
  

  return $matches;
}

?>

It basically just checkes all available enabled views and checks if it has a page display. Then it gets the URL and adds it to the the matches in CKeditor

The obvious error with this is that it loads all views instead of just the required ones as defined by the autocomplete

Update

<?php


/**
* Implementation of hook_ckeditor_link_TYPE_autocomplete().
*/

function ckeditor_link_views_ckeditor_link_views_autocomplete($string) {

  $matches = array();
 
  $query = db_select('views_view', 'v');
    $query
      ->fields('v', array('vid', 'name'))
      ->condition('v.name', '%'. db_like($string) .'%', 'LIKE')
      ->orderBy('v.name')
      ->range(0, 10);
      
    $result = $query->execute();

    foreach($result as $view) {

	  $view = views_get_view($view->name);
	      
	  $matches[ $view->display['page']->display_options['path'] ] = $view->human_name;
	
	}
  return $matches;
}

?>
devin carlson’s picture

Status: Active » Closed (fixed)

As anrikun mentioned in #10, you are now able to link to any view which has a menu item.

elpino’s picture

I think it would be worth it to include this in addition to views that already have menu links enabled, because you don't always need to set menu links for a certain page display even though you would want to be able to link to it's path.