Posted by robin.keith on January 17, 2010 at 11:03pm
9 followers
| Project: | TinyMCE Node Picker |
| Version: | 6.x-2.0-beta4 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Peter Törnstrand |
| Status: | closed (fixed) |
Issue Summary
Hi there.
I'm using TinyMCE (via the wysiwyg module) and node picker. I can insert a link fine, but when I preview/view the page, the links I created are shown like this:
[url=/drupal/Wedding-Marquees]Weddings[/url]
i.e. not converted to an actual link.
How to I get it to convert it? (I've got both PathFilter and PathAlias modules installed) I've tried various versions of NodePicker and it seems to happen on all of them.
Also, ideally, it would be great if it could generate links like internal:node/345 to link the node by id number, and the let the path filter module generate an url.
Thanks for any help.
Robin
Comments
#1
It looks like some kind of input filter is the cause of this.
As to producing links in the style internal:node/xxx this can be done by modifying the nodepicker_nodes view. Another user in this thread had the same problem: #570032: Should to produce node alias or use internal relative url's (node/xy)?.
#2
I've turned off PathFiler and PathAlias modules and also the GMap and lightbox modules (the only filters I can see installed) .
The content is using an inputFormat of full HTML. I've tried turning all of the filters off for that inputFormat but the [url] is stilll not converting.
Any ideas where I can look to sort this out? I've removed and readded the link to the page.
Thanks for the other posting - looks interesting if I can get the basic thing working.
Thanks
Robin
#3
This is very strange. The Node picker module explicitly inserts a Selected text tag. This must in some way be converted by some input filter (or TinyMCE plugin) enabled on your installation.
It looks like the link produced on your installation is in BBCode format, that might help you track the problem?
#4
I tried disabling every filter and module i could find, but no luck. so i installed bbcode, and switched it on in input filters, which started work. So is bbCode required for this module?
When u say node picker inserts a 'selected text' tag, can u explain a bit more? (link didn't work for me) From the other thread on getting it to reference nodes directly eg. internal:node/345 does it mean i can tweak the view to generate output in the format I need? If so, a. how to do that? b. is that maybe why it's generating [url] tags?
Thanks for you help.
R
#5
No, BBCode is not a required module. I don't know why your setup is acting the way it does. It must be some kind of plugin/module or maybe TinyMCE itself has been modified?
In order to insert a link with the module you have to first select some text and then click the button. This has changed in HEAD and a new release is coming later today.
Yes, you can tweek the view. The link that get's inserted get's it data from the "Insert link" link in the Node picker. The format of that link decides how the inserted link will look like. The view by default does not generate BBCode style links.
#6
Hi blixxxa,
Thanks, I looked further and realised that the regular add link option was doing the same thing. Turns out its a feature of using tinyMCE via the wysiwyg module. Even without the BBCode module installed, Wysiwyg has an option for bbcode, which was turned on (http://drupal.org/node/603072). So it's adding the link in good old fashioned tag format now.
I've also changed the nodepicker view to work with pathfilter (internal:node/234 style) urls. I'm a Drupal nearly-nubie, so it took a while. Below is instructions for anyone else is trying to do the same thing (don't know if it's the best way but it works). (Maybe NodePicker could have an option to use PathFilter syntax without having to configure separately?
Thanks for all you help, and thanks for NodePicker - it's a great add-on!
Cheers
Robin
How to enable site authors to link to internal pages (by node ID)
Linking by NodeId means that internal links won't break if the url changes. (It does of course mean that if you replace a page with another and give it the same url, links using this method WON'T be updated - and will still point to the old page!)
Install: Wysiwyg, PathFiler and NodePicker modules. Install TinyMCE as per Wysiwg instructions - this assumes using TinyMCE but other editors should work too.
Make sure all the above modules are enabled in the Modules page, and appropriate User > Permissions are set.
Configure Input Formats
In Site Config > Input Formats:
Select the appropriate filter, click Edit
Check the Internal path filter checkbox is checked.
Configure Wysiwyg Module
Select TinyMCE as the editor.
Click Edit
In Buttons and PlugIns section, uncheck BBCode and check NodePicker
Click Save
Configure NodePicker to produce internal links
from Views > List ... select nodepicker_nodes > Edit
Add the NodeId field (NID):
In the fields box click + (add)
In Groups dropdown choose Node
Check the Node:Nid checkbox
Click Add
Check the exclude from display checkbox (so its not displayed in the list)
Click Update
Edit the link:
In the fields box, click on Node:Link Action
Check the Rewrite the output of this field checkbox
In the Text box, add
<a href="internal:node/[nid]">Insert Link</a>Click Update
Then click Save to save all the changes.
#7
Thanks for the guide. I will put a link in the README.txt file to this post to help users wanting to do the same thing.
#8
This is just what I was looking for. However, the 'internal:' substring gets filtered out by the time it gets into my editor.
Do you guys have any idea which module / filter is responsible for this and how I can change this ?
Thanks for your ideas, help.
M
#9
Indeed, this was also what I was looking for, but in setting this up, the insert link (even when its rewritten with internal:node/[nid]) only inserts the 'node/[nid]' part of the link.
I've had a look through the tinymce_node_picker/js/dialog.js and can see its not being stripped out there. It looks more like the view is stripping it out when it renders the link (i.e. its fine in $field->options['alter']['text'] but in $field->last_render the internal: part is removed).
As a temporary work around, I created a views-view-field--nodepicker-nodes--default--title-1.tpl.php and set the link there with the following code:
<?php
$keys = array_keys((array)$row);
$search = array();
foreach ($keys as $k)
$search[] = "[$k]";
echo str_replace($search, array_values((array)$row), $field->options['alter']['text']);
?>
Another quick note to those great instructions by robin.keth - make sure when you add the nid field, that you order it to be above the node title link, as it won't be in scope for views to use.
#10
Here's an alternatively more elegant, but less readable (imho) approach to the views-view-field--nodepicker-nodes--default--title-1.tpl.php hack above:
<?php
$row = (array)$row;
$res = preg_replace("/\[([\w_#]*)\]/e", "\$row['\\1']" ,$field->options['alter']['text']);
echo $res;
?>
#11
I had the same error (option). When I added links with WYSIWYG editor (with TinyMCE) I got [url=...] tags instead of
<a>tag. To fix it I simply disabled "BBCode" option in "Site Configuration -> Wysiwyg -> Profiles" (edit format -> Buttons and plugins). Hope this will help somebody.#12
I have a few questions on how to implement your changes:
1. Where are you placing this code within views-view-field--nodepicker-nodes--default--title-1.tpl.php?
2. How does Views know to use views-view-field--nodepicker-nodes--default--title-1.tpl.php?
3. Where in the file directory does views-view-field--nodepicker-nodes--default--title-1.tpl.php belong?
Thanks for your help.
#13
Hey Shawn,
1. the code there is what you could use for the entire views-view-field--nodepicker-nodes--default--title-1.tpl.php. I've attached the file in full, just download it and remove the .txt file extension from the end.
2. It knows, because you would have created the title-1 field as per robin's instructions.
3. You need to put the file in your theme folder, i.e. in here: /sites/all/themes/xyztheme/ - after adding the theme file there, then you might need to tell views to discover the template file which can be done by clearing the theme registry.
Hope that helps!
#14
That helped a lot! Thank you!! :)
My problem was that I had the tpl file in my main theme but I'm using the newest admin module (with Tao theme) so I had to put the tpl in the sites/all/themes/tao directory.
This module is a usability life saver for our clients! Just had a client meeting and she was ECSTATIC! Awesome job everyone!
Shawn
#15
Had the same problem and then unchecked BBCode in the Wysywig editor buttons list. You have to re-paste in the links again and re-save...then it worked!
#16
@Martynov Yup, it helped me. Worked great. Thanks for posting 8^)