Option to NOT link to NODE

Jeremy Toaster - June 30, 2009 - 06:26
Project:Web Links
Version:6.x-2.0
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I was wondering if there was an option to NOT link the title to it's NODE?
I find that sort of redundant and confusing for viewers to my site.
If there were an option to either have the TITLE of a link, link to it's URL or to it's NODE, I think that would be most useful!

Thanks a lot!

jeremy

#1

NancyDru - June 30, 2009 - 13:48
Status:active» postponed (maintainer needs more info)

If you use a theme that does not build the title for you, then you can change the theme template. Otherwise, you will have to create a node-weblinks.tpl.php in your theme to not link the title. However, it is pretty much standard Drupal practice to link the title to the node, which is why it's done by the theme.

#2

Jeremy Toaster - June 30, 2009 - 14:13

Yea I just thought you could have a choice on that.
Because if a viewer goes to http://www.mysite.com/weblinks they see a list of Titles and Links, that is as deep as they need to go, all the links are right there. Now if they click on a TITLE, which is common practice to send you to that LINK, they are taken to a NODE which displays them the same information they just were looking at, then they have to click AGAIN to actually get to the LINK now, something they didn't have to do in the first place.
So I think it is a bit misleading to the viewer.
If there is an option to either A) have the TITLE be the URL link as well or B ) have the TITLE NOT link to anything at all or C ) have the TITLE link to NODE
I think those options would be very helpful.

Thanks

jeremy

#3

NancyDru - June 30, 2009 - 15:55

We used to have those options, but doing so required very specific view code in the module that prevented a lot of normal Drupal things from happening. For example, just to allow comments required extra code that everyone, not just those using comments, had to load and execute. Voting and rating modules simply did not work at all.

One of our long-term goals, as well as a major driving force behind 6.x-2.0, is to move to a more standard Drupal way of doing things so that you have the flexibility to do what you want to your site and so that other modules can easily "bolt on" to Web Links. As a result of this, the title is produced by the theme layer, not our module.

We do produce either the URL or what we refer to as a "Visit" link (customizable) for the user to click on. That link can be made more inviting to your users by altering the CSS.

#4

jonathan1055 - July 3, 2009 - 19:35

Hi Jeremy,

I wanted exactly the same result as you, and achieved it by creating my own hook_weblinks_preprocess() function as follows:

<?php
/**
* Implementation of hook_weblinks_preprocess().
*/
function mymodule_weblinks_preprocess($node) {
 
// the default is to have a link for the title, but we don't want this, so change it to ordinary text.
 
$variables['title'] = $node->title;
}
?>

I stored this in a general module that I already had created to do various miscellaneous bits of work on my site. If you dont have such a module then you can put it in your theme's template.php file and call it yourtheme_weblinks_preprocess().

Hope this helps

Jonathan

#5

NancyDru - July 3, 2009 - 20:24

That would only work if you have the "Show the node title" set to "yes." Many themes will automatically create the title linked to the node and you will end up with double titles showing (see #419334: Duplicated title). We could add this option with the caveat about that setting.

#6

jonathan1055 - July 3, 2009 - 20:56

That would only work if you have the "Show the node title" set to "yes."

Actually that does not seem to be the case (atleast not for me). I had to set 'show the node title' to 'no' because my theme (based on Zen) was duplicating the titles. But the preprocess above is definitely working and I do not get my titles turned in to links. I think that $variables['title'] is always the one which is shown, and it is extra title that is in weblinks-link.tpl.php which is optionally turned off if the setting is off.

At least, that is how I explained the situation to myself when I worked out my solution above.

Jonathan

#7

NancyDru - July 3, 2009 - 21:21

Perhaps most themes are that way, but a quick look at Bluemarine shows <h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2>, which will link it any way. My "standard" theme, Pixture-reloaded, does the same thing that Bluemarine does; Nitobe and Ad-Novus also do this.

I have added a setting to do what your module does.

For these themes, the simplest thing to do is to make a copy of node.tpl.php and call it node-weblinks.tpl.php and remove the linking code.

#8

NancyDru - July 3, 2009 - 21:23
Status:postponed (maintainer needs more info)» fixed

committed to -dev.

#9

jonathan1055 - July 4, 2009 - 16:40

Hi Nancy,
Sorry, you are right. I did this work a week or so ago, and had mis-remembered how I achieved it. Yesterday I looked at my hook_weblinks_preprocess, saw the change to $variables[title] and thought that is how I did it. But now I recall that this did not do it and I had to create node-weblinks.tpl.php and remove the href tags just like you say above.

and apologies to Jeremy for misleading you!

Jonathan

#10

NancyDru - July 4, 2009 - 17:22

Well, it's all part of the module now. Fell free to update the documentation with how to do this... ;)

BTW, the module does the check_plain, so the theme should not.

#11

Jeremy Toaster - July 4, 2009 - 18:23

Thanks a lot for sorting and figuring this out! I am downloading now and will be putting it to use!
Woo Hoo!

#12

jonathan1055 - July 5, 2009 - 18:58

I've just downloaded dev dated 5th July and I can't see where these options are, nor can I find the group option for whether to collapse a specific group. I'm sure they are here somewhere but I cant find them! I was under the impression that these options were now accessed by the 'edit group' link, but all that gives me is the group name and description, and the advanced options has the weight and parent group. I am logged in as user 1.

Maybe they are here somewhere, and I'll feel very foolish for not seeing them!

Jonathan

#13

Jeremy Toaster - July 5, 2009 - 20:03

It's under "Link Settings"

These settings control the way individual links display on the main links page.
Show the node title:
Yes No
This makes the node title link to the node. For some themes, this will need to be disabled.

Link the title to the node:
Yes No
If your theme automatically provides a node title, set this to "No." If you see duplicated titles, then set this to "No" and see if that resolves the problem.

But it doesn't actually seem to be working for me yet.
I have cleared cache's and such, but it still links.

jeremy

#14

jonathan1055 - July 5, 2009 - 20:16

Ah ha! I knew about the duplicate title option, but I didn't read the description properly to notice that there was a new option beneath. The text seems a bit confusing, because the description under 'Show the node title' appears to be for the second option, and the text under 'Link the title to the node' seems to relate to the first option. I will look at the code and see which variable is actually doing which option, then maybe things will be clearer.

Jonathan

#15

jonathan1055 - July 26, 2009 - 14:58

OK Jeremy, apart from the descriptions which have got put under the wrong options, I think it is working. However, getting the result you want may also require two other things, though.

Firtsly, as hinted above (in #1 and #9) if you have a theme which is creating its own titles then you need to select Show the Title=No. This means that the standard node title will be the one showing and the weblinks-controlled title will not be shown. BUT this also means that the option for 'Link title to the node' will have no effect, because it is not that variable which is being used to display the title. To solve this you need to take a copy of node.tpl.php, call it node-weblinks.tpl.php and store it in your theme's directory. Edit and change the line which displays the title from:

<?php
   
<h2 class="title">
      <
a href="< ?php print $node_url; ? >" title="< ?php print $title ? >">< ?php print $title; ? ></a>
    </
h2>
?>

to:
<?php
   
<h2 class="title">
    < ?
php print $title; ? >
    </
h2>
?>

(nb. spaces added between < and ? to allow posting here)

Secondly, if your theme does not provide the title, so that you don't need to create the template file above, then you may not be getting any title. This could be due to the option for selecting Full Node instead of Teaser. The weblinks-controlled title is only shown when viewing the teaser version of the link. This is a bit odd, but I'm sure Nancy had a good reason for doing it this way. All my links are full-node so I had the 'Full Node' setting on, and was not seeing the weblinks-controlled titles at all, even when 'Show Title' is Yes.

So, depending on what your theme does, you should now be able to get what you want. I might even write this up for the documentation that Nancy has suggested.

Jonathan

#16

NancyDru - July 5, 2009 - 22:42

I fixed the reversed settings descriptions and clarified the one for linking the title to say that additional theme changes may be required.

As for the teaser/full setting, this can be confusing. Even the core maintainers have that confusion and it is a bit better in D7. For theming, "teaser" refers to how much data is shown, whereas "page" refers to whether the node is displayed by itself (full page). It is not impossible that I got myself confused as well. If that is the case, please open that as a new issue so it can be tracked better.

#17

dbeall - July 14, 2009 - 14:47

project-- Moving from 6.16 to 6.x-2.0...I have set aside a whole day to upgrade to the new module.. and I am trying to jump through all the extra moves to make it work. At the end of the day, if the results are not as good as the old version, I will be going back to the old one, which had much better style among other things. The old one worked great, was easy, you were done !
This may be the Drupal way, but it makes setting up a simple web links page a project.. I think this may deter people from using the module. just my thoughts on it....

#18

NancyDru - July 14, 2009 - 15:02

In the CSS issue, I noted that switching from the standard CSS to the minimal CSS made almost no difference. So the standard theme CSS should be showing the links page fine right out of the box. You don't give any details about why it's looking strange on your site. I'll be happy to help if I understand what's troubling you. I suspect you'll also be happier with the -dev version which will become 6.x-2.1 momentarily.

However, I would appreciate it if you would open a new support issue as this has nothing to do with this one.

#19

dbeall - July 14, 2009 - 18:58

sorry, i was on this thread because of the links opening a node.. i ended up doing a fresh install of 6.16, it is a beautiful piece of work.

#20

NancyDru - July 14, 2009 - 19:33

And unsupported. And you can't use most add-ons.

#21

NancyDru - July 23, 2009 - 14:04
Status:fixed» closed

Included in 6.x-2.1.

#22

johnmullin2003 - July 24, 2009 - 14:36

Hello all,

I've just installed the last stable release 6.x-2.1 but this feature seems not working.

Link the title to the node: --> NO

Any idea? Have I to change anything in template?

Thanks all for your help.

edit: solved using #15 posted by jonathan1055. thanks.
but dunno how to modify link-to-node ---> link-to-url on image-attach-body

#23

johnmullin2003 - July 24, 2009 - 10:55

and more...for each link I set one Image (using image attach).. but the image is linking to node too.
Are there any settings to remove link or linking to url ?

#24

NancyDru - July 24, 2009 - 14:54

If using the "Show the node title" option doesn't fix it and ends up with duplicate titles, then this is a theme problem. You can either do as you did from #15 or open an issue with your theme developer to fix it.

As for the image link, we don't have any control over what Image Attach does, you will have to open an issue in their queue. Web Links isn't even aware that Image Attach is there.

#25

johnmullin2003 - July 24, 2009 - 15:00

Thank you, NacyDru, for your quick and excellent support! :-)

#26

johnmullin2003 - July 24, 2009 - 15:00

Thank you, NacyDru, for your quick and excellent support! :-)

#27

NancyDru - July 24, 2009 - 15:35

I have updated the documentation here: http://drupal.org/node/293092#no_link

#28

NancyDru - September 20, 2009 - 21:33
Status:closed» fixed

I have committed a fix that changes the "Link the title to the node" setting to now allow the title on the links page to go to the site URL as well as the "visit" link.

#29

NancyDru - September 26, 2009 - 23:25
Status:fixed» closed

Included in 6.x-2.3.

 
 

Drupal is a registered trademark of Dries Buytaert.