1

I have used views to create a page to look like the below screen shot. I have used trim to limit the description of the body to 200 texts. I have added "Link" and have termed it as "Read more". Is it possible to change the "Link" text in our webshop as "to shop"? I want this change to happen only for that specific item. For the rest it should be "Read more"

Views screenshot

2 Answers 2

2

Probably going about it the wrong way, you could either set a custom text field on your node called 'Link text' then output that as a field and check 'Link this field to its node' in views.

Or you could use the 'Link' field type contrib module, then output that as a field, this will allow you to set custom text as the link label, but you will also need to supply the link itself. But this will allow more flexibility.

1

The Views UI does not offer if'fing. And - frankly - I almost gave up using the Rewrite options, as I noticed I'm more productive with tpl files. If you want to alter the link depending on some context, try using row theming then.

  1. Add a field named Taxonomy Term: Term ID. Make sure it outputs raw, without any classes, wrappers, and stuff
  2. In the Theme Information section: pick a theme tpl file that suits you, put it on server and rescan template to make it recognized.
  3. Put your field where you want: print $fields['tid']->contents

  4. In the PHP code, make a variable that will form the link text depending on the context you wish

  5. Build the link using the l() function, using the variable as the first parameter. The url for terms is 'taxonomy/term/$tid'. I don't remember if the l function replaces it with alias, if not, use drupal_get_alias_path on the url, to have an aliased link.

That should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.