Custom Fields, linking to a separate download page? - php

Afternoon all,
I have some Advanced Custom Fields set up, which allow the user to download files which are appropriate to a certain product.
For example, if the product was 'Product 1', the files would be 'Product 1 size' etc. This works perfectly, using the following:
Brochure
This adds the file which is added on each individual page, as in ACF I have set the location rules as shown in the screenshot
Now, the issue is as follows.
I need to create a whole new page, called downloads.
This page, will list all the products in my page, and then need to have the downloads available (the Custom Field File). Now, because this field is set up to show on the product pages, I am completely unsure as to how to show the downloads on a seperate page, because using
Brochure
is technically not telling me which product this is for.
I hope this makes sense.
EDIT:
I completely forgot to mention, this information will need to be inside a table, and I am currently using TablePress, a plugin.
So it would go like:
Prouduct --- Category --- Download
Thank you all!

After you have edited your question, my first answer does not make sense anymore. So here is what I suggest now:
A. This is the solution to what you actually asked
Install the Reveal IDs Plugin so you can see in the admin panel what post-IDs your products have
Look up the ID for a specific product
In your TablePress table-cell you paste the ACF-shortcode:
Download brochure
post_id="12": this is the ID of your product-post which you can look up with Reveal IDs.
I already tested this right now, so I do know it's working.
B. Another solution that is more a question
Your ACF field 'brochure' obviously contains a URL to a file which might be available in your WP media library too?!
When this is the case you don't need the ACF field for your table. You can just:
click "Advanced Editor" (when working with the table)click into a table cell
click into a table cell
click "Add files" and link to your file directly this way
Maybe that is an option too.

I think I understand what you're trying to do. This should point you in the right direction: http://www.advancedcustomfields.com/resources/query-posts-custom-fields/

Related

Wordpress - Hide specific fields to certain user role on back end

Is there a way in which I can disable/hide specific fields from the "page form" in the back-end? I have currently test two plugins but none of them meet the requirement that I have, like for example this plugin "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
I'm sorry that the options are in spanish but the capabilities options are for example: "edit pages", "edit other people's pages", "publish pages", "delete pages"... What I want is to hide certain sections to the "editor" user role from the page form:
Is this even possible?, and if not, what alternatives do I have?, the thing is that I'm afraid that whoever is in charge of editing will end up messing up with the pages...
Use Adminimize plugin It will resolve problem easily.
This plugin changes the administration back-end and gives you the power to assign rights on certain parts.
In most cases, the plugin "Adminimize" that Tech Sourav mentioned will work just fine, but since this page I'm working with is using some annoying custom content editor and other theme tools, the workaround that I ended up doing was:
Create a custom post type with the "Custom Post Type UI" plugin.
In this case I will only and always have 3 pages that have this "modifiable" price field, so once the custom post type is added I added 3 entries to this custom post type (here I will show you just one).
I'm also using the "advanced custom fields pro" plugin in order to create this price field into my entries.
When the custom field has been created there's this option inside the same previous form that allows me to show that specific field just created into specific post types entries, so I made up the rules in order to show this field in the created custom post type entries:
In this example I'm just showing you the rule for one entry, in order to make it appear on the other 2 entries, I would just click in the "agregar grupo de reglas" and select one by one.
Once this custom field and rules are configured correctly, I should see now the custom field "precio" inside my specified entries form:
After saving the entry with the updated custom field value, I will now check the post id and save it for later (we're going to need it):
According to the documentation of Advanced Custom Fields plugin I can show the saved value of certain input within certain post with the shortcode: [acf field="{$field_name}" post_id="{$post_id}"], in this case I will change the values to: [acf field="precio" post_id="1372"] and paste the code into the section of the page that I will show this:
The builder that this page is using has an element called "code block" but you can use it in the equivalent element that allows you to paste code from your theme.
After saving the changes, now the only thing that I have left is to restrict the ability to edit pages to a user with the "editor" role, for this I will use the plugin that I mentioned before in my question called "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
As you can see, I will not let editor users to mess up with the pages post types, so with this, they will only be able to edit the custom post type that I created, which even if they write something inside the content of that custom post type entry, the website won't be affected at all. This may be a little bit hacky but it works...

Display custom field tabs in front end article edit page in Joomla 3.x

I have been looking for a solution to display custom field tabs in the Joomla
front article edit page.
http://www.aixeena.org/extensions/aixeena-easy-cck
Aixeena Easy CCK
I installed the plugin of aixeena, two custom field tabs: the Extra content and Extra content 2 are displayed in the backend admin article edit page, which is great. But we also need to let regular edit their article and enter values in custom fields under those two tabs. Any idea how to achieve this?
I tried a couple of other sites posting the solution of adding custom fields in article, such as Rating region described in the site:
https://docs.joomla.org/Adding_custom_fields_to_the_article_component
I was not able to make the Rating tab displayed in the front end article edit page neither.
I tried the fieldattach, it does supports custom field tab ( which is the group name of custom field), the list field type only contains static values, we have to define fieldset and field type through xml file.
Any help is greatly appreciated.
I just finished writing a couple pluginsto do this similar thing. I wrote my own plugin to add the extra fields - but it looks like the one you've already used is very similar.
I had a really hard time figuring out how to add the fields for frontend editing as well. But I finally figured it out.
First, you're going to need to copy the com_content form edit.php into a template override (/templates/your_template_name/html/com_content/form/edit.php).
In that file, add the extra fields you have. You'll need the name of the field that you put in the xml file for your plugin you already have. Add them right before/after the fields that are already in the file, that you want your fields to appear before/after. Example:
<!-- CUSTOM begin custom fields -->
<?php echo $this->form->renderField('video_url', 'attribs'); ?>
add all your fields in there - replacing 'video_url' with your own field name. The plugin you already have already saved these fields to the 'attribs' part of the article, so you can leave that there.
The plugin that I used to create the fields for the backend is a really simple one based off of this tutorial https://zunostudios.com/blog/development/203-how-to-add-custom-fields-to-articles-in-joomla
What I'd suggest is to go ahead and create that plugin too. Except in the zfields.php file, change "$app->isAdmin()" to "$app->isSite()" - make sure the xml files have the same names as your other plugin xml files, so they save to the same place, and you're done. The fields will show up on the frontend edit form now.
What I'd really recommend is to get rid of the Aixeena plugin, and just make that easy plugin using the tutorial above - it's super easy. When you make it, duplicate the "if ($app->isAdmin())" section, copy it right below it, and change "isAdmin" to "isSite" - and now you've got the entire thing, all your custom fields, both frontend and backend, all in one place. Now just do the edit.php template override, and you'll have them displayed in both the front and backend. I hope that helps - if you need I can upload more example code.

Wordpress - display media on page

A client wants a full page full of PDFs, and an option to be able to assign a PDF to a page automatically.
For example, conveyancing.pdf would appear on downloads.php (along with several others), but also have an option to tick 'yes I want this PDF to also feature on the conveyancing page'. Is this possible, and if so how would you approach it?
If I made a custom post type for the pdfs, is there an option to list all the pages it can appear on, like you'd tick categories but this would be 'pages'?
"a full page full of PDFs"?
Do you mean a page with links to multiple PDFs on the server?
Chrome / firefox and maybe IE have a built in PDF viewer and there is an option to save, download or print.
How to Upload & Link to a PDF file in WordPress
if i get you right, you want to upload pdf files from the admin panel and attach them to pages.
since you didn't specify what you already done, i will start from the beginning.
I've done this before on some project, i needed to let a client upload documents to post type page and custom post types. you can create a new custom fields on your code if you like too but i think if you'r out of time, you can installed for example the WCK plugin because besides of options like create new custom post types or taxonomy easily, it also let you create custom fields with repeater (which is not freely in every other good custom field creator plugin).
create with the plugin a new meta box and then the document field (you will need to do it for each post type). after that, you will see the new custom field on the post type you've been chosen, upload a document for the test and on you theme code call to get the field, check this link to get the detailed instructions.
after it will work for you you will want to add an option to attach some documents to other page by some checkbox right? you can create another custom field (checkbox) under the same meta box so it will Appear with every document field and then get the value on the code theme to check if it checked or not, that way you can control what documents will appear in the template you want to get by the checked checkbox of document ("show this document in other templates").
the problem with this should be how to get the id's of the pages who have the selected checkbox to the current page, i didn't try it but maybe you call all the pages with WP_Query and in the array use the specific post type you like and the custom field parameter to get only the pages with the check box, after that you can run a foreach on the array and use a condition to check for the value of each page checkbox, if it true get the custom field (document) and in the place to insert the post id use the id of the post in the foreach so it need to bring you the specific document. i would love to hear if it worked for you, good luck!

Add link in custom post-type - Wordpress

I have a custom posttype in Wordpress 3. I would like to every post of this type to have the option to add a link. Basicly this will be a link that refers to another page/post whatever on the site.
There should be only one link for each post of this type. And i would then need to extract this link in my template files. Basicly im creating a post-type "Slideshow" And each slide-item should be connected to one page or post. So when you click a slide you will be taken to the defined page.
i know i can do this by using a custom-field. But then i would need to enter the whole url every time. I would like a feature similar to that of the wordpress WYSIWYG editor link button. So i can add a link to "existing content" easy.
Anyone know of any tutorials or similar on how to do this?
Thanks!
bit surprised no one has mentioned this plugin "Related Links"
Wordpress plugin Related Links
It adds a metabox to your edit forms. You can link to related content or put in external URL.
It allows links to posts, pages, media AND Custom post type - check its type on the Settings page of the plugin after install. It uses a similar search/browse facility to the normal WYSIWYG link insert feature!
What post-types does it apply to? If you are using on a custom post type, then check all the post-types you want to be able to link to - it still shows the box on this post-type itself.
It can accept multiple links, but one will work of course. Then you use the get_related_link() function in your template to output this and format as you like.
If you just want to make a link between the two posts, rather than insert it in your post content, I'd recommend the Posts 2 Posts plugin. It'll allow you to create links between posts without having to remember the full URL.
Edit:
I haven't used it, but I suspect the cardinality argument should help you limit the number of links - see the wiki.
And you can certainly access the connections in your templates - I have. Once you've registered your connection type, you can just call get_connected:
$venue_details = p2p_type( 'exhibition_to_venues' )->get_connected( $post->ID, array(
'posts_per_page' => -1,
'connected_orderby' => 'order',
'connected_order' => 'ASC' )
);
It seems to me that the best method to accomplish this would be to add a custom meta box to all posts and post types (see here:http://themefoundation.com/wordpress-meta-boxes-guide/). Within this meta box, you can simply query all posts that you would like to include in a dropdown. You can then select the post from that dropdown, obtain the ID of the post selected (use as data attribute in the option field), and then return the permalink for that ID. This will then allow you to simply select the post, rather than having to know the actual URL each time.
Another method would be to attach a piece of unique data to x post (most likely utilizing custom fields), and then also attach it to y post. In this way, you could use a function to automatically append the link to the displayed post. You would do this by querying the posts in the database, match the custom data, and if matched, display the link to that post. This would allow the entire thing to be automated, and you wouldn't even have to select anything. In my opinion, the title field should actually be sufficient for this, since both posts are different post types (you should be able to title them the same), and would likely make your query a bit easier/shorter since you would simply need to find the post that matches the title, and then link to the permalink.
I can elaborate on all of the above further, with code samples as well, but in my opinion, the question is slightly too vague to write a custom script example for this scenario.
I would hope the above would be sufficient to get you going.

Adding values to a magento dropdown or multi-select product attribute while adding a new product

I'm wondering if anyone has found or written an extension that would allow a magento website administrator the ability to add values to their products attribute while adding the product. For example, if I sell books and want the book author to be in a drop down list so that it would be used in layered navigation, it seems odd that I would have to add the author via the attributes section before adding the product. From a workflow standpoint it really makes sense to have an "add new value" button next to the drop down on my add product screen.
Anyone have any thoughts or insight?
It's a piece of cake to do, if you know jquery and the (if I may guess) extremely simple model behind magento.
As the other guy said, throw some money and I'll do it ;)
Otherwise, real easy -> find where that dropdown is generated, add a button next to it that opens a popup which you fill "create a new thingie" stuff, create button -> +create +close +refresh your dropdown.
Definitely easy.
And considering the attribute dialog already exists in the tool you cold probably take most from there and just add the popup handlers / button / +refresh .
This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, import images and media galleries, reindex, refresh cache, media and price rules automatically. In addition you can backup the entire database in SQL format.
So from above, once you make the csv file, you just have to add the Author header and it would build the list from there. However, the attribute must exist first. I am using this method for the creation of my own manufacturer attribute options.
AMartinez_CustomImportExport
Can't say I have, but I've developed something similar that creates an attribute and adds it to multiple products, it's completely possible, you just need to add something that will call the add attribute on the add product page or change the new product flow to allow a new attribute and add it if needed.
Don't let them scare you, it's not as hard as some people might describe :)
My curiosity finally took over my laziness and I managed to create the module author requested. It's available on github.
Please feel free to check it out and update it if you wish. Maybe in some near future I'll post it on Magento Connect, if feedback is good.
Here's some code that checks if an attribute value exists and adds it if it doesn't: http://www.magentocommerce.com/boards/viewthread/26234/
Shouldn't be too hard to integrate it with the "Add product" form.

Categories