Hi I am looping through a channel in EE2 and I am outputting all of the fields values but how do I output the fields title that I labeled it in the backend?
CODE:
<!-- Loop to out put a field called Location -->
{exp:channel:entries channel="vacancies" disable="pagination|member_data|categories"}
<p>{vacancy_location}{title}{/vacancy_location}: {vacancy_location}</p>
{/exp:channel:entries}
DESIRED OUTPUT:
<p>Location: Some Location</p>
What worked for me was installing SafeCracker module that is shipped with EE2 and using its {label:} tag
http://expressionengine.com/user_guide/modules/safecracker/index.html#label-my-field-name
You might be able to accomplish this via the SQL query tag, but generally speaking the labels assigned to fields in the back-end are intended to be for use only within the Entry Publishing/Editing screen. The labels for these fields that are seen by the people entering content into the system may not always necessarily be the same labels you want to expose to visitors to your site on the front end.
Like #stoep mentioned, you may have better luck writing a custom plugin to handle this, if writing SQL query tags in your template won't end up as a viable option.
You can't.. The only way to get it is by extracting it from the database. You could write a custom plugin for the task. Another option is to put the field label in the Global Template Variables.
Edit: I quickly created the plugin for you -- you can grab it at https://github.com/Stoep/pi.field_information , place it in third_party/field_information/
Usage:
{exp:field_information channel="news" field_name="news_content" information="field_label"}
{exp:field_information channel="news" field_name="news_content" information="field_instructions"}
Related
I see all sorts of people asking this but no solid answers. I want to take text from a textarea form where users can enter their bio and then insert it into the bio field in mysql. This might be fairly easy normally, but alas, it seems nearly impossible with WordPress. I have to use the "Php for posts and pages" plugin and for some reason, the php script I have cannot be found (404 error) no matter where I place it. Then I thought I would try to just make the form and php all on one WordPress page, but it apparently can't be done like on a normal php web page. Anyone have any experience doing this? Any approaches that are known to work?
You can make form using normal php and insert it into mysql.
You can do this by making page template in wordpress.
http://codex.wordpress.org/Page_Templates
I've went through the same process! :)
My solution was:
Installing a PHP insertor plugin (specifically this). It's lot easier than creating a template.
I used it like this (inserted into the post's source):
[insert_php] include('myphpfile.php'); [/insert_php]
Then the included PHP's contents will be processed and printed out inside the page's body (the article's main part), so you don't have to create the html, head and body tags.
Then came the problem with posting form data to a page like this. This was because some of my form's fields kinda conflicted with WP's variables.
Some of the conflicting field names I've noticed: info, name
Just have a look at your form' field names and replace them to something else, and everything will be fine! :)
PS.: It's possible to put the form and the form data "receiver" in the same PHP script. I've done so and it worked in this scenario.
PS. 2: Optionally, you can disable the annoying auto-paragraph-insertor wpautop stock WP plugin, as it's affecting the included PHP's output. There is a per-post wpautop disabler plugin: Toggle wpautop
I'm trying to add the editiedon field to the modx manager pages so my users can edit the value using this bit of documentation as a start point:
http://rtfm.modx.com/revolution/2.x/case-studies-and-tutorials/adding-custom-fields-to-manager-forms
Which does work, but:
how can I make that a date/time field?
how can I place it in the settings tab of the given resource?
Isn't input type="date" the answer to the first question? I'm not sure how you would do the second part, unless you managed to get the rendered content and splice it in there somehow (unless theres som hidden specified method).
Otherwise, you could always solve it with regular form customization. You'll want to create a TV of type Date, and give it a custom default data through a snippet, that just fetches the current resources editedon value. I guess you only need to update the resource/update form set. Under the template variables tab of the set, make sure your TV is connected and change the region value of it to "modx-resource-settings"
There are two different ways which have their own pros & cons.
At first you can use template variable with Date type. It gives you correct ExtJS component for dates and you'll see calendar in TV's tab.
If you'll choose this method you have to create a plugin which invokes on OnBeforeDocFormSave event. There you can redefine modResource editedon property from your TV and it will be saved in proper way. Also you may invoke another event(OnLoadWebDocument). There you can set modResource editedon property from you TV if you want to see correct data.
Pros:
fast calendar integration to the one of modResource's tab
you can use Form Customization for security reasons. It's rather easy and from the box.
Cons:
Additional TV which complicates modResource updating process a little bit
Another method is more complicated (you need skills in ExtJS).
Create plugin which invokes on OnDocFormPrerender event. You can add JS to the modResource page there. Your scripts should render new custom tab to the document where you can add your special field with calendar. So there is special ExtJS component in MODX for these purposes. And of course you need events from first method for loading and updating editedon value.
Also you can just render special field to the existing tab instead of creating new tab and rendering your custom field to it.
Pros:
you don't need TV anymore
it's flexible
Cons:
it's more complicated and takes time
P.S. You can view Xlexicon github repo. There you can find example of rendering new tab and manipulation with modResource properties.
Also you can check modAvatar extra for MODX. There is an example of manupulation with existing tab.
This is probably a fairly unique situation, however I am writing some custom code for myBB. It is essentially a small CMS whereby part of it allows users to define blocks and block areas and fill those block areas with code.
The way I want this to function is that the user creates a block area and then defines its position inside a template. As the user can define any block name they want and place them in any area they want, I am having trouble getting my head around just how to handle this in code.
My thoughts were that I could have the user define a variable in their template named block_blockarea_name, I could then grab that the variable and then parse the name of the variable remove "block_" then use the rest of the name to check for any block that is assigned to that area name. I am trying to do this on a custom page rather than through a plugin itself.
The only other option i have is to have a marker like and use a find and replace on that.
Just wondering if anyone has any ideas or suggestions on a better way to handle this.
Are you asking how to include a template in a custom PHP page on MyBB? I always use this to output things like the header, maybe yours would work in the same way:
<?php
output_page("{$header}");
?>
i am developing a web app app in which there are several results,
i need make a search box such that when i start typing into the search text field the results start filtering themselves on the basis of content of text box...
"Scenario"
I get list of registered user on a page
the list is nicely formatted and tabulated
there is a text box at the top of list
when i type something in it, the list gets repopulated with matching result just like "Windows Start Menu Search & Files"
i can not use grid-view as i am not developing in ASP, also that i am not going to use grid view as i need to be able to customize the formatting etc of the results as much as i can...
i cannot be anymore specific... please any Suggestions, where to look, or what to look for?
Try this jQuery plugin: http://datatables.net/
Any solution you choose will have to either operate on the complete table (no pagination), or use Ajax.
Seems that javascript (or your favourite framework) perfect suits your needs.
Your JS code should just filters matching rows, and since your table is html, its rows formatting is up to you.
I am somewhat new to both Wordpress and PHP, and I wanted to get advice on the best way to tackle my problem as I have had little luck doing it successfully so far.
There are two jobs I want to handle:
First of all, I want to have a conditional include on my home page that does the following;
Find a custom post type home_content (only ever going to be 1 post, which is ID 76 - if that helps)
Display 3 custom fields from that post... the values for today_on front_widget_a & front_widget_b
(I guess a secondary question would be - can I even pass shortcode through a custom field, because that's what those widgets are being generated from, is shortcode from a plug-in)
That's pretty much it. I've tried various combination of get_posts and get_post_meta without much success. Either I get some syntax errors I can't figure out (and trust me I've combed my code many times for missing semi-colons and the like). That or I get a result that makes no sense.
The second one is a bit more difficult.
Basically trying to turn a part of my Wordpress into a bit of a CMS-style feature. Basically, I have 2 additional custom post types, one called tag_page_layout and one called tag_page_data.
When a Tag in a post is clicked on, I want the Tag page to grab custom field 1 from the tag_page_layout, and then a couple custom fields worth of data from tag_page_data.
I probably wouldn't even need the two post types if I took the time to learn the PHP or HTML code for making tabs, but again, I'm using a plug-in for Wordpress shortcode (which, if you see above - I'm not even sure is going to work right - of course if its not I'm willing to make multiple of these 'layout' posts so each [tab:NAME] shortcode bit is in it's own post-content area.
So... the tag page will basically have a big bit of code that runs before the loop.... it knows its on a tag page so it starts loading Custom Field 1 from the tag_page_layout, which is essentially a bit of code that starts up a Tab-separated data presentation area. Then it's got to take the tag clicked and match it with the same tag ID from custom post type #2 - the tag_page_data group. Then it will grab the first 3 or so fields from that page, swap back to the layout post, throw another custom field from there to start another tab, and so on and so forth, until a [tab:END] and it runs the loop.
I could include all my various attempts and bits of code that never worked or half worked, but I've been around so many circles trying to construct this. Like I said, my coding knowledge is limited but I can usually feel my way around, however these finer points of trying to make Wordpress a little more CMS-like seem to be harder for me to grasp. Any help would be appreciated!
As far as using shortcodes in custom fields go, this should help you out, where XXX is your custom field name.
<?php
$var = apply_filters('the_content', get_post_meta($post->ID, 'XXX', $single = true) );
echo $var;
?>
This apply's the standard filters wordpress automatically runs on regular post content, allowing it to process your custom field and convert the shortcode.