dynamic WordPress custom meta boxes - wordpress

I'll try and give an example what i want:
(this isn't what I'm doing, but it seems like a decent example of how I'd like it to work)
Imagine we have a custom post type (CPT) of 'houses' and one of the custom meta options for this CPT is 'bedrooms' - obviously, different houses have different amount of bedrooms, all of which have different properties. So, I'd like to be able to allow the user to add several different properties about a bedroom i.e.
Dimensions, aspect, number of windows and floor type
When the user has added these details for the first bedroom, if the house has a second bedroom then I would like them to have an 'add bedroom' button and another set of these meta boxes is added so they can fill out the details about bedroom 2.
I understand that I'll need some javascript to add this facility (and something I don't mind writing) but what I'm struggling with in my poor, useless brain is how to save these to the database. I want to achieve this using WordPress meta so that I don't add any unnecessary database tables and I'm sure it's possible I just can't quite fathom the principles of how to save the data.
Pointers to any tutorials would be brilliant, or some examples of plugins which already do this kind of thing would be very gratefully received.
here is a screenshot to get an idea what i want to do.
Solution:
I have found solution here, it might be helpful for someone.
https://wordpress.stackexchange.com/questions/25478/custom-post-type-metabox-array

You are basically after repeater metaboxes. A few metabox classes support repeating fields. One worth checking out is http://www.farinspace.com/wpalchemy-metabox/
I wrote a plugin that uses repeating metabox fields that doesn't use wp-alchemy if you want to dig through it. http://code.google.com/p/css-thumbnail-sprites/

Related

Category with children organization: wordpress

Good day kind crew. I haBe a issue. what I am trying to do is this: a tennis league with 5 divisions. These 5 divisions are located in everytown and those towns in states. I am using ACF and pods. On the state archive page. We would like to choose the state and then on the specific state page we would see the divisions terms. And when you click the division you see all post from that tterm. We have a custom template for the taxonomy but want to limit how many template pages we need to create. If we go with categories than we have to make a custom template for every town/division. Any suggestions on best logic for this making it easy to use on front end without losing admin organization. We set up category hiearcy but we're looking for a better way because we need to allow for user to fill out form and populate post. At this point we have decided to use categories unless someone has another option. Categories just feel sloppy on admin side with children. Thanks for your time.
I'm not sure I understand the question, and thus am not sure I'm on the right track with this answer.
I think you're looking for towns/divisions to have content that can be customized by users. There may be a more WP specific way to do this, but a simple way would be to have a db table with these elements associated with the post id, for example post_id, town_desc, town_mascot, etc. Then, in the WP template, run a query to see if custom elements exist. If not, echo some default text, otherwise echo the custom element text from the db. I think I'd also have the default text be different based upon the level, i.e. with states, divisions, and towns all different based on their level.
Your answer might lie in simply working with custom fields, perhaps with
https://wordpress.org/support/article/custom-fields/

Drupal sections division

I'm doing an intranet for a company that has multiple projects going on internally.
The idea is that each project has only 3 distintive things: its homepage, a small theme variation and its posts. Everything else is shared: every user can post into every section, it's just a way of visually dividing information.
Each project will have a path:
[...].com/projects/project1
[...].com/projects/project2
[...].com/projects/project3
My initial idea is the only 2 content types to have an extra (select type) field which is SECTION. Then, I make a .tpl for each homepage with the variations and calling the views that filter posts by this SECTION field.
This would would work but I'm missing 2 aspects: will I be able to use the section field value in the path auto module? Say I post a node with "corporate" as SECTION value. Will I be able to make it to [...].com/projects/corporate/post-title ?
Second issue is I don't know how to make [...].com/projects/corporate/post-title to load the theme for the "corporate" SECTION
Is my SECTION field approach right or is there a better solution? If anyone know an answer here or article somewhere that addresses this scenario please just point me to it.
Organic groups may be somewhat of an overkill but it could work http://drupal.org/project/og

Drupal Taxonomy associate to content

I have some content I need to start categorizing. We've built the system a while ago, the content is growing a lot so now we're finding a few years later we should start categorizing this stuff. How can I enable taxonomy for this content?
Thanks
Jeff
You can absolutely enable taxonomy on already existing content types and nodes. There will be no effect of course until people actually edit the content to add terms.
In order to categorize the content I would recommend http://drupal.org/project/views_bulk_operations
It's awesome and saved my in the past during migration cleanup! Throw on some "exposed filters" for node type, then add some field columns that will help you sort things, make the table columns sortable, so you can sort on the fly.
Then add in your allowed actions on the view style to enable updating taxonomy terms in bulk.
This should take care of our needs.
BTW: If you find yourself changing your mind about categories you should make use of http://drupal.org/project/taxonomy_manager to MERGE terms and thus the associated content.
You can add term reference field to your content type and this will give you a field through which you can tag your content and categories it.
Then as doublejosh mentioned you can use Views Bulk Operations (VBO) module to categories your content in bulk as you said you have lots of content to categories.
Definitely tough to go back and get content categorized, but you have better options that just Views Bulk Operations... unless you just have a few categories then that will do the trick.
You can use varying levels of machine learning to automatically tag content. I've had lots of success using Open Calais to tag 100s of 1000s of nodes coming in via Feeds in the past. This is fairly exciting once you get it going :)
OpenCalais module
Auto Categorise
Auto Tagging

Organising Custom Content for Wordpress

I am already very confused as I am typing this thread out. Please forgive me if my query is a little too difficult to understand.
I have an existing Real Estate Site that I intend to move 100% into WordPress. The existing site has one backend for listings and another blog section for reviews.
You can probably see why I have decided to make the move to a full WordPress powered site. Maintaining both ends of the site is both tedious & cumbersome.
I have read and understood Custom Post Types & Custom Taxonomies and how they work. I am rather excited about implementing them. However there is some content I am finding difficult to organise.
* An existing database table of about 4,000 Condominium Projects
Each entry in the Condominiums table has some "bio-data" like Year Completed, No. of Units, Facilities, Amenities etc.
Currently each listing in my site has an ajax query that fetches information from this table on demand.
In the new site, I intend to have a link to the respective condominium in each property listing.
This link should display information about the specific condo and display 'results' of matching listings.
Also, some condos have long article reviews done for them. In my current site, these reviews are displayed in the blog section. Separated altogether.
So here's my question.
How would I connect everything together. A duplicate perhaps? Taxonomy & Post for each condo? That will mean over 3,000 unique entries. Wouldn't that be an "overkill"?
If it is a taxonomy, the link will probably display all posts (listings) that have that condo name. But it wouldn't link to an actual page of either it's review or bio-data.
Any thoughts will be very much appreciated... Please feel free to ask if I have missed out any vital information!
Thanks in advance
The seems very straightforward to me and a perfect fit for WordPress (and I shudder to think of doing anything in Drupal you don't have too; and this from someone who developed in Drupal for 2+ years...)
Anyway:
Each condo gets stored in a custom post type.
All the "bio-data" gets stored in a custom field. Alternately you could create a taxonomy called "bio-data" and have a term value for each of the options but this won't work well for things like "SqFt" unless you do ranges (i.e. 1200sft-1300sqft) because terms can only be used for "true/false" attributes (i.e. either it applies or it doesn't) and not for specifics like exact offer prices, etc.
The long articles can just be stored in the "content" section of the condo post type (unless you have multiple per condo then you can either store in comments as #Jan Fabry suggested or you can create a custom post type "review")
Like I said this is really straightforward. Of course I've lived and breathed database apps for 20+ years so it comes second nature to me. Any questions, just ask...
This was how I managed to solve my own question!, Ironically enough, MikeSchinkel had an almost identical answer, so I accepted his answer instead.. So here's what I have:
A Custom Post Type for Condominiums labelled 'Reviews' in the admin section. The property 'Bio-data' is in custom fields. This Custom Post Type has a rewrite rule:
array( 'slug' => 'condominium' );
That way, I managed to have each Permalink to show something like:
http://domain.com/condominium/post-title
I have added a page called Condominiums and had it set to use a custom template - which basically shows the latest posts of condominiums with reviews. I also intend to extend the template for it to show a Search Condominiums function.
Added relevant taxonomies that can be searchable - like Brands & Developers.
I have already converted previous reviews to this. The last thing I will have to do will be to post all the Condominiums from the condominiums database to the wp_posts table using this Custom Post Type.
This is the part I am crossing my fingers for as I will have to see if the rewrite rules are going to significantly slow down my site as this will be 4,000 entries. This issue has been recently brought to my attention here
http://core.trac.wordpress.org/ticket/12935
I will update this thread once I have completed the importing - since this is the only place I have posted a question and have it answered - if anyone might be interested!
Thank you for your suggestions. I hope this helps someone else who is in a similar predicament.
Would it work if you view the Condominiums as posts, and the reviews as comments to these posts? This would keep them together, and is conceptually not even too far from the original intention. You can put the extra information in custom fields and tags (which gives you free searching capabilities). Then you should see for yourself if you still need to create a custom post type, or just do it with regular posts (why not?).
But yes, you are stretching the original WordPress concept a little. Drupal or some other CMS might be a better option, and have more plugins that are suited to your situation.

Drupal: Content in blocks from node_reference fields?

After only a few weeks of working with Drupal I've come up with a recurring problem, which I don't really have an optimal solution to, so I'm hoping that someone here might be able to give some best practice pointers.
What I have is a region inside my node.tpl.php, which is populated with blocks that display content from two different CCK fields of the type node_reference. This works fine when displaying a single node. The problem appears when I need to use a view.
For example, lets say I have a news listing, and a single news item view. When I display the single news item I can use the news node node_reference field to reference whatever material I would like to have in my sidebar, but when on the news listing view I would like to reference nodes separately. What would be the best practice to solve this?
I'm having a few ideas, but none seem like the logical choice, how would you do?
My understanding of your problem is that you don't want the blocks to display on the view page and you want the block information displayed inline with the node.
The first part is easy, you can modify the block visibility settings to not show up on the path where you have the view.
The second part will depend on how you set up your view. If you are using fields you can simply add fields for the node_reference and they should display. If you are using a node view, you will have to override the template and create a template which displays the node reference field.
If you want further explanation please comment and I can clarify
After reading my question I realize that it was explained pretty badly, so I'll try again, and also tell how I solved it.
The Problem
On normal "pages" (when displaying only a single node), I have a sidebar that shows something similar to banners, which are either random, or I can select one or many that should always be displayed on the sidebar. This is solved easily when displaying a single node, using a CCK node_reference field. The problem is when using a View that displays multiple nodes, for example a news listing-
The Solution
In my case I could solve this by creating additional fields on my default Page content-type. These fields were called view, display and arguments. In my tpl.php I then embedded the news listing view inside a page, lets call it News. This way I gained great flexibility, and also helps the News page to know where it is located in menu structure.
Final comments
I have yet to discover if there are any drawbacks or dangers in doing this way, but if there are, feel free to share them with me :)
I tend to want to create my own modules, which create blocks and reference the database directly. Then I put the blocks inside of panels, this seems to be more flexible for me than using views and cck fields etc ...

Resources