hellomoto Posted January 8, 2015 Share Posted January 8, 2015 I have a price_currency field that references child pages of a page Currency. Its names are three-letter currency codes, and the titles are symbols: $, euro and pound. I tried inputting both $ and $ as the title instead for $ to see if it would echo; it's not. How can I get these values to appear? $item->price_currency outputs the ID, but $item->price_currency->name doesn't even work either... Link to comment Share on other sites More sharing options...
Macrura Posted January 8, 2015 Share Posted January 8, 2015 you should maybe reference the name which is already the 3 letter code; the title also can be the same uppercase code; where you are echoing you could use a function to convert to the right entity function get_cur_symbol($price,$cur) { $symbol = ''; switch($cur) { case 'USD': return '$'.$price; break; case 'AUD': return 'AU$'.$price; break; case 'CAD': return 'CA$'.$price; break; case 'GBP': return '£'.$price; break; case 'JPY': return '¥'.$price; break; case 'EUR': return '€'.$price; break; case 'CHF': return 'C'.$price; break; case 'CZK': return 'K'.$price; break; case 'DKK': return 'k'.$price; break; case 'HKD': return '圓'.$price; break; case 'HUF': return 'F'.$price; break; case 'SGD': return 'S$'.$price; break; case 'NOK': return 'k'.$price; break; case 'NZD': return '$'.$price; break; case 'PLN': return 'z'.$price; break; case 'SEK': return 'k'.$price; break; } } 1 Link to comment Share on other sites More sharing options...
hellomoto Posted January 8, 2015 Author Share Posted January 8, 2015 Yeah that's what I was going to do. I will. But why is that happening? I just tested another template type I have, renamed the title to '$' (sans quotes) and it appeared on the frontend... Link to comment Share on other sites More sharing options...
hellomoto Posted January 8, 2015 Author Share Posted January 8, 2015 It's the pages themselves or the field. I changed their titles to their names and still can't get them. Couldn't get the names anyway. Link to comment Share on other sites More sharing options...
apeisa Posted January 8, 2015 Share Posted January 8, 2015 I have a price_currency field that references child pages of a page Currency. Its names are three-letter currency codes, and the titles are symbols: $, euro and pound. I tried inputting both $ and $ as the title instead for $ to see if it would echo; it's not. How can I get these values to appear? $item->price_currency outputs the ID, but $item->price_currency->name doesn't even work either... $item->price_currency returns page id like it should. $item->price_currency->title should give you what you are after. If these don't work, then make sure you have single page reference for the field price_currency. If this $item->price_currency->first()->title works, then your field returns multiple pages (PageArray). 2 Link to comment Share on other sites More sharing options...
hellomoto Posted January 8, 2015 Author Share Posted January 8, 2015 Thanks, apeisa. ->title is what I tried first... but, I never tried ->first()! Of course! That's what it was all along. That I should have known... at least... Thanks a mil! Link to comment Share on other sites More sharing options...
apeisa Posted January 9, 2015 Share Posted January 9, 2015 Better solution might be editing the field and have it return single page instead of PageArray - and then remove the first(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now