Closed (fixed)
Project:
Custom Formatters
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Dec 2011 at 09:38 UTC
Updated:
27 Jan 2012 at 00:18 UTC
Jump to comment: Most recent file
Comments
Comment #1
summit commentedHi, I am not a programmer, but maybe one of you can built a formatter from this piece of code from An abstract of à solution On the twitter module?
http://drupal.org/files/issues/twitter-245453-1.patch
If so thanks a lot in advance!
Greetings, Martijn
Comment #2
summit commentedHi,
1) I patched shorturl to D7: http://drupal.org/node/1033046#comment-5400618
2) I enabled custom formatters on D7 17 okt. dev version
3) I added the instructions from http://drupal.org/node/608810#comment-2532040 for the link module custom formatter
I needed to change this to:
for not getting errors as: Notice: Undefined variable: element in eval() (line 1 van /httpdocs/sites/all/modules/custom_formatters/engines/php.inc(79) : eval()'d code).
What I want is that the static link field title is shown with the shorturl as link-url-field.
Now I do not get an error. But I also not see the formatter.
What do I do wrong please?
Attached the custom module I made as the method shown on: http://drupal.org/node/608810#comment-2532040
Can anyone help please to get this formatter working?
Comment #3
summit commentedHi, I see this issue where may be something can be learned to get it working: http://drupal.org/node/1110132#comment-4837998
EDIT: tried the following as formatter:
$variables['#items'][0]['url'] because of this issue: http://drupal.org/node/1110132#comment-4588726
I am on travel now. Please help to get this fixed. Would be awesome to be able to use shorturl as custom formatter for a link-field!
Greetings, Martijn
Comment #4
summit commentedHi, I am still trying this, and I have some results.
1) I changed back the formatter to:
2) I had to remove split() and replace it by explode() in shorturl.engine.inc
Now I see the title and as url the shorturl.
A) But clicking on this shorturl, I am not redirected to my long-url, which should be the action.
EDIT: Module short url (on homepage http://drupal.org/project/shorturl) says: http://example.com/sDf will redirect to the original long URL with HTTP 302 code
But I got the shorturl, but it is not redirected outside the site. the long url is an external url.
B) I would like to use the variable in attached image. How should I handle this instead of $variables['#object']->title?
Can somebody help with this please?
Greetings, Martijn
Comment #5
deciphered commentedHi Martijn,
The variable in the attached image should also be available in the $variables object, just do a DPM of that in your Custom Formatter and then navigate to the object appropriately. If you need help, just stick
dpm($variables);above your existing formatter code then supply me with an image of the expanded output so I can help.Cheers,
Deciphered.
Comment #6
summit commentedHi Deciphered first a great 2012 to you!
1) See here where the variabel is:
What should I put into the custom formatter?
Formatter itself works, only not with url variable /?= ..I think that is a shorturl problem.
Greetings, Martijn
Comment #7
deciphered commentedBased on that output the path to the variable you want is:
$variables['#instance']['settings']['title_value']However, it should be on #item or #items as well, which would be the better choice.
Comment #8
summit commentedHi Deciphered, the output path worked, thanks!
Only problems now are with shorturl_shorten($variables['#items'][0]['url']));
1) the shorturl is allways the same
2) the redirect url doesn;t have the query string from the original url.
EDIT: Could these things be connected. Could it be that $variables['#items'][0]['url'] which is used for the shorturl_shorten already is the url without query string, and therefore (because all nodes have same http://wintersport.sunweb.nl/reizen/ peace of url) the shorturl is always the same.
The error is than that the query string is cut off likewise: http://drupal.org/node/1397700#comment-5443574
greetings, Martijn
Comment #9
deciphered commentedWhat are the values of the URLs being passed through shorturl_shorten()?
I know some shortening services don't handle query strings at all yet others do. If your not using Clean URLs you really should be.
Comment #10
summit commentedHi,
It was a link module problem, see this issue-patch http://drupal.org/node/1309658#comment-5168960
Thanks for your help with this issue!
greetings,
Martijn
Comment #12
summit commentedHi,
I have still one tiny thingy with the array of something. How should I get the variable in this line, like http://drupal.org/node/1379704#comment-5439796
I just can't get it right. I tried:
But no success. Can you help me please?
EDIT: I found it!!
Thanks!
Greetings, Martijn
Comment #13
deciphered commentedAnything that comes from an object/class should be referenced with an arrow (->) and anything coming from an array should be referenced with square brackets ([]).
Look at the output a little closer:
#object is a class, therefore anything referenced from it should be referenced by an arrow
Everything else are arrays, therefore they should be referenced by square brackets.
So you should be using the following code:
$variables['#object']->field_prijs['und'][0]['amount']Comment #14
summit commentedThanks for your quick reply and explanation. I am not a programmer, many thanks for your help!
Greetings, Martijn