Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: TEDER - Popup radio bar
Thanks, Gil. I’ve been working through your answer and the good news is that my original problem was solved by replacing $(cbx).find('.cbx_image').val(cbx_data[3]); with $(cbx).find('.cbx_image img').attr('src',cbx_data[3]); (as you suggested above). Now the thumbnail images show up in the article when I reopen the article to edit!
However, I’m having a problem when I use the code below to try to isolate the image id:
var cbx_img = $(this).find('.cbx_image img').attr('src').replace('\/images\/','');
cbx_img = cbx_img.split('.');
var cbx_img_id = cbx_img[0].replace('t','');
var cbx_img_ex = cbx_img[1];
content_boxes_data += cbxf1+'~|~'+cbxf2+'~|~'+cbxf3+'~|~'+cbx_img_id+'~|~'+cbx_img_ex+'~||~';
It is cutting up the url into sections with http://www and mydomain, etc. separated by ~|~ And it removes t’s in other parts of the url, including the ‘t’ in txp_img I’m sure it is something I am doing wrong!
Really I all I want to do is to be able to easily output the full size image on the front end of the site. I’m not sure how to do that when the full url in the body contains the thumbnail t.ext. Maybe there is a way to use txp tags or another plugin to strip out the t in the page/article template instead of going to the trouble in the custom ui script.
Thanks again for your help in guiding me through this process!
Offline
Re: TEDER - Popup radio bar
photonomad wrote:
It is cutting up the url into sections with http://www and mydomain, etc. separated by ~|~ And it removes t’s in other parts of the url, including the ‘t’ in txp_img I’m sure it is something I am doing wrong!
Good morning Stacey,
The code I posted above it is just an example, you need to change it to fit for you,
If you didn’t used the code I posted that let you save only the ID# and the extension, and you DO still save the full URL, then you need to change the value in the .replace() function.
For example if your full URL is: http://example.com/images/123t.jpg
then your replace function will be: .replace('http://example.com/images/','');
we are replacing your site domain URL with nothing, which means that we delete it.
(You can also use a split function instead if you like to.)
now what you got it is 123t.jpg which is the ID# and extension,
so we split it into 2 parts cbx_img = cbx_img.split('.');
now you got cbx_img[0] = 123t, and cbx_img[1] = jpg
we create to vars using them just for it to be pretty
var cbx_img_id = cbx_img[0].replace('t',''); which is the ID# and we are removing the t from it to get only the number.
var cbx_img_ex = cbx_img[1]; = extension (jpg/png/gif)
So now you can use these two in the output of content_boxes_data as long with the others.
Yes you don’t need the extension at all for your site code, that’s why we got TXP for, but you do need it to load it back in your custom UI when editing.
photonomad wrote:
Maybe there is a way to use txp tags or another plugin to strip out the t in the page/article template instead of going to the trouble in the custom ui script.
Sure there is – rah_replace is what you are after.
<txp:rah_replace from="http://example.com/images/,t,.jpg" to=""><txp:variable name="my_image_full_url" /></txp:rah_replace>
(or just only replace the “t” if that what you like to do)
You can wrap that line with a variable for it will be more comfortable to work with and then use <txp:image /> to output the image.
<txp:variable name="my_image_id"><txp:rah_replace from="http://example.com/images/,t,.jpg" to=""><txp:variable name="my_image_full_url" /></txp:rah_replace></txp:variable>
<txp:image id='<txp:variable name="my_image_id" />' />
Offline
Re: TEDER - Popup radio bar
If one of the fields contains html characters (for instance, a chunk of Flickr embed code), the data is converted to entities at some point via (I think) rah_repeat. I am having trouble figuring out how to convert the data for the field/variable back to actual html characters. Hints/tips greatly appreciated. I’ve tride using html_entity_decode in the customui.js without results (I’m probably using it wrong). Or, I’m wondering if there is a more simple way to convert back to html characters using txp tags in the page/article? I’ve searched for plugins, but most seem to only convert html characters to entities. Thanks in advance for any hints/tips.
EDIT: I’ve ruled out involvement from rah_repeat.
Last edited by photonomad (2012-10-10 02:06:57)
Offline
Re: TEDER - Popup radio bar
Ok. My brain kicked in. Just needed to escape=”“ for the custom field. duh
<txp:rah_repeat value='<txp:custom_field name="customui" escape="" />' delimiter="~||~">
Offline
Offline