Issue with "modify taxonomy" - drupal

I'm working with Drupal 6 to create a feed collecting site. I import the original feeds via the feeds module and copy their tags. But I also want to assign a category (terms from second taxonomy) according to the author name to be able to divide the content in a unified way.
I want to use the rules module (rules-6.x-1.2) to assign these categories upon import. I use the following steps:
ON event Content is going to be saved
IF textual comparison ([node:author-name], TheAuthorName)
DO Modify node taxonomy terms (saved content, permanently, add the selected terms)
I select the terms to be added as "-none selected-" for tags and "TheCategory" for categories.
Now, when I import the feed, the category "TheCategory" is added to the content, but the tags vanish.
This happens also if I select "Replace existing terms with selected ones" or "Replace terms within same vocabulary" for the action. Upon editing, always the radio button of "add …" is selected, regardless of what I entered previously. And yes, I clicked on "save".
Is this the right way to do what I want? Why isn't it working? Could I do this with another module maybe (I don't need rules for anything else …)?
Thanks for your help!

Ok, so I found out that the right trigger to do this is "new content is created" (which I somehow couldn't get to work beforehand).
So, I ran the rules module in debug mode and found that the rule was triggered, the filter returned TRUE and the modify node taxonomy action was successfully accomplished. But the taxonomy was entirely unchanged.
I played around a little and postponed a "save content" action on the newly created content. Turns out, this fixed the problem and now everything works as I intended.
Still, there are some flaws:
I checked "permanently apply changes", but it did not do anything.
I unchecked "permanently apply changes", but upon editing again, the box was checked again (probably the setting was not saved to begin with)
The same holds true for the radio buttons for the type of "modify node taxonomy" action which was obviously not saved
Maybe this can help someone.

Related

Why would WooCommerce Product Attributes disappear on save

I have a WooCommerce store that has products with attributes that are associated with variations. When I save products, the attributes disappear (and therefore the associated variations do, too). When I re-add the attributes and save the product again, the variations come back as they were. (Note that this means attributes don’t always disappear - only when they’re not manually added before saving. )
No errors are logged.
I'm looking for some insight as to why this would happen.
I had the same issue since I use Ozisti theme for my site, too.
The workaround was to do NOT USE "Save attributes" button on product page. To save attributes changes USE "Update" (product page - on the top/right of the page).
The problem has been solved with Ozisti ThemeREX support team. They sent me new files:
wp-content/plugins/trx_addons/components/api/woocommerce/woocommerce-extended-attributes.php
wp-content/plugins/trx_addons/includes/plugin.wp.php
and now it works fine.
Regards, Jacek
I think I had a similar problem.
WordPress 5.1.1
WooCommerce 3.5.7
Ozitsi 1.0.2 Theme by ThemeRex (here was the problem)
Solution summary: Add attribute, add options, press SAVE ATTRIBUTES (attribute row folds) -> UNFOLD IT immediately - if you don't see options inserted a second ago into the Comboselect field read on.
In my case plugin ThemeREX Add-ons (shipped with Ozisti theme) was the issue. It added extra attribute types, so I could turn variations between dropdown select, image, color and button types.
After few hours of debugging I noticed that when attribute was set to one of the new types, UPDATING PRODUCT did erase all added attributes -> and by extension variations.
After ADDING ATTRIBUTES again (without SAVE ATTRIBUTES button - just adding attributes and UPDATING product) all was back in place.
Notice: when you SAVE ATTRIBUTES the row with options closes, the variations become available. But when I opened the attribute row after all AJAX saving was done it turned out that there were no OPTIONS placed in this Wordpress combo select of attribute I just edited.
So on UPDATING PRODUCT WooCommerce saved empty attribute options into DB.
This might not be perfect solution but I solved this by modifying WooCommerce's meta-boxes-product.js
I commented out line 465 and added another line to close the row:
$( '.product_attributes' ).html( response.data.html );
$( '.product_attributes .woocommerce_attribute.open .handlediv' ).trigger('click');
I didn't trace everything to the roots but makinkg it work for this single project is good enough for me at this point.
You probably use other plugins then me, but maybe they do something similar to my case.
So try to SAVE ATTRIBUTES and then immediately open attribute row again and check if selected options are inserted.. if not.. try my solution.
This Happen to me This Year. I was debugging my store for 3 days.
Solution:
I load a css file on Wordpress back office with these lines:
.save_attributes, .save-variation-changes {
display:none !important;
}
This makes WooCommerce Hide 2 buttons.
Save Attribute and Save Variation. So clients will be forced to use the update button in the product page. I'm still not sure if this is a Woocommerce bug or other plugin but for some reason, if I pressed one of these 2 buttons I would lose all my variations.
I have similiar solution with #Maciej Dejewski using Woocommerce v3.6.5.
On file /plugins/woocommerce/assets/js/admin/meta-boxes-product.js or /plugins/woocommerce/assets/js/admin/meta-boxes-product.min.js (depends on your admin page calling the javascript - you can check it via inspect element)
But instead adding line
$( '.product_attributes .woocommerce_attribute.open .handlediv' ).trigger('click');
Just commented out this
$( '.product_attributes' ).html( response.data.html );
Working fine for me
Here's the screenshot
Hope this would help!
After debugging for a hour, it turns out that my variations only disappear when not each attribute is selected. However, some of my product's attributes have between 10 and 150 entries..so that is the downside when using this method.

Ensure a Rules Link only shows in a set type within a Panel Page (Drupal)

I've created a Rules Link (in a View) which shows in a users dashboard using Drupal v.7.27 as CMS for a number of (similar) projects using the same functionality. The Rules Link is set to 'trigger' a rule when the user clicks "Post Content" (the Rules Link). The Rules link works fine and fires the trigger which then follows the simple conditions I've set and only because I've created Variant Panel pages for each User Type, the Rules Link only shows on the ones I've set the Panels Page Access conditions (ie Role: Content Manager).
However, I've noticed that as I'm also using the Support Ticket Module, then "Post Content" Rules Link is also showing on the top of the list of a users Support Tickets list (only for testing here, but it's shows my test comments from both user and Admin user) AND* it also shows on a link on all other Node types.
Clearly I don't want the Rules Link to show at the top or bottom of any other content type other than a Node (ie on the Post New Content Panel Page). At the moment is set within the Rules "Edit Bundle" section to show across 'none' as there is no option to force it to show ONLY on my Dashboard Panel. I'm also using the 'Render' Rules option and tried every option but to no avail after a few hours.
I've had to set the option to 'Nodes' in the Entity type which the Rules Link is attached to (because my Article data is a Node within the Panel Page) and it says quote:
'Bundles to which the link should be attached to. If left empty, the link is not restricted for any bundles' under the Bundles section.'
Furthermore, within the Views entity created (used to set the 'Rules Link' into any Node), there is no option that I can find which enforces the Rules Link to only be limited to a particular node, which in my case is a custom Page Panel. Maybe I lack current Drupal knowledge or simply have over looked an issue.
I know I need to learn PHP (yes, currently working through CodeAcademy!) but in order to get the thing working functionally, can anyone advise on what is going wrong and why the Rules Link is showing n other Node types and for a PHP novice like me at this stage, could I simply put some PHP in somewhere that would ensure the Rules Link only shows on a set Content Panel on my custom Panel Page.
I hope I have been clear enough and help at this stage is most gratefully received. Thanks in advance.
EDIT:
Actually the Rules Link is showing on all other Nodes (see above*). I've noticed that Bundles might be the key here? I've todate not used Bundles if that helps anyone?
RESOLVED
I found the source of the problem.
The answer is to ensure that the "Render Entity" is un-ticked in the option box:
"Show link when entity is rendered
If checked,the link is shown when viewing an entity to which the bundle and the visibility conditions apply. Only applies to displayed entity types and if no addition variables were added."
I hope that helps any future readers.

Change block content based on changes in another block

I am experienced Java/C++ programmer, but totally new to Drupal/PHP.
Short question:
How do I refresh all the blocks in my page, based on the input to a particular block?
Exact Scenario:
I am looking to create a website with display and behaviour similar to http://www.google.com/finance. I have started creating a custom module for this in Drupal 7, So we want to have:
a top input block where users can enter a particular company's name.
a main block which starts with general content (e.g. tables plus latest news about the economy etc). As soon as a company is selected in block 1, this changes to news and tables about the chosen company.
a side graph block displaying some relevant graphs etc. Again, when no company is chosen, this could display the general graphs (e.g. S&P, Dow Jones, NASDAQ), and when a company is chosen, this displays the details for the chosen company.
The way I see it, the website works in a "current context" for the user. So, perhaps I can set a session level variable in Drupal, and refresh all blocks based on the current value of this variable?
However, I am not sure how to achieve this, and what is the best way to do this? (AJAX? Taxonomy?)
Any pointer, hints, suggestions, examples, sample code are most welcome.
This is how I would approach this problem based on how you have described it. The majority of the functionality being handled by the Views module.
I'm assuming you have the following setup:
A Taxonomy vocabulary called "companies" which has company names as
terms.
A Content Type called "News", which has news information about
companies. Most importantly it will need a taxonomy field where you
can select which companies it is related to (lets call this field "company_reference")
A Content Type called "Tables"(?). I'm not sure what information you
want in your "tables", but again it's most important that is has a
taxonomy field to reference companies. (can be the same field "company_reference")
The Majority of the functionality you are looking for can be built using the Views module.
I would create a View (let's call it "Company Data"). the view is going to have three different displays, each of type "block".
Display 1: Input Block
Set the display name to something meaningful, say "user_input_block"
For this block, leave FORMAT settings as they are.
For the FIELDS settings, just have "Content: Title" (does not
really matter for this block).
For the FILTER CRITERIA settings, add a filter and select your
"company_reference" field, set it to auto-complete, expose the filter
to visitors and (under the "more" section) change its Filter Identity
to "company".
For the PAGER settings set it to display a specific number of items and set it to '1'. (this will limit the data this block retrieves)
Under the Advanced section change the "Machine Name" so comething meaningful, say "user_input_block"
Still in the Advanced section click on "Theme: Information". this will display a list of the different custom template files you can have for this view. For "Display Output" write down the last template suggestion in the list, it will be something like "views-view--company-data--user-input-block.tpl.php" ("views-view--{your view name}--{your display name}.tpl.php"). Click on "Display Output" and copy the PHP it lists. (this is the views default PHP for the view).
In a text editor/IDE (whatever you use) paste the copied PHP code and save it in your custom theme with the template name you wrote down. Edit the PHP and either comment out or remove the section that says "<?php if ($rows): ?>...<?php endif; ?>" (this will remove the returned content from the display)
So to review the view display that was just created will (using the custom template) display a block with just a field that as the user is entering a company name it will autocomplete. It will then submit the form and pass it as a GET variable to the current url (www.yoursite.com/yourpage?company=users company").
Display 2: ** Main Block**
Set the display name to something meaningful , say "company_news".
Set the FORMAT settings to which ever you like (or leave as is)
For the FILTER CRITERIA add a "Content:type" filter and select your "News" and "Tables" content types.
In the Advanced section click "add" next to "Contextual Filters". )A contextual filter is passed in the URL, we are going to be grabbing the value that was passed from the Input block.) Select "Content: field_company_reference" as the field and click "Apply"
for the "when the Filter value is Not available" section select "provide default value"
for the "Type" select "PHP code" and the PHP code will be something like this "return isset($_GET['company']) ? $_GET['company']:false;"
for the "When the filter is available of a default is provided", check "Specify validation criteria", set "Validator" to "Taxonomy term", check the "Companies" vocabulary and for "Filter value type select "Term name converted to Term ID"
for "action to take if filter value does not validate" select "display all results"
To review, this view display will display a block that lists "news" and "tables" content. If the GET variable "company" is passed (from the input block) then the content of this block will be filtered to display only content that is associated to that block.
Display 3: ** Graph Block**
I'm not exactly sure what data you want to display in this block (or rather where it would be coming from) but if you set it up like how I described setting up the Main Block it will filter by company (use the same contextual filter and content that has the company taxonomy reference field).
The one difference with this approach is that it requires the page to be reloaded when a user enters a company into the input block. If you want to avoid this then you could make the following changes;
for the main block and graph blocks instead of using a contextual filter use a regular filter for the Company reference field (same settings as were setup in the input block). For both these blocks under the Advanced section, set "Use AJAX" to "Yes", and use custom CSS to hide the exposed filters from view.
with a custom module (or with your custom theme) that adds additional JS to the page. Have the JS triggered by the field in the input block, when a user enters a value into it, the JS copies that value into the exposed (but hidden) field for the other blocks, triggering Drupal to reload them via AJAX with the passed filter.
I haven't tested any of this and it is just theoretical based on my knowledge of Drupal, but it should start you out on the right path.

Different pages for showing different fields of a single node in Drupal 7

Is it possible to elegantly do this? The idea is, a node of content type "project" has a lot of fields, its url is something like node/5. I want to show some of the fields on that page, and others on node/5/extra, kind of an "extended" page that the user only loads if he is interested in that content (lots of images, in my case, that would slow down the main node page considerably).
I tried the Display suite module, unsuccessfully (it seems it's not really meant for doing what I want). I also saw this blog post, which explains how to add a custom display mode to a content type (other than the Default and Teaser ones that come by default), but I can't get it to work the way I want to either.
I guess you could create a view having the node ID as a default argument from URL. Then you can choose which fields to show or hide

Drupal 7 View to list content created by logged in user

I've just started using D7 and was trying to set up a system where people can add a couple types of content and associate one with the other via nodereference.
I only want users to be able to see and work with their own content.
To achieve this in D6 I used a view for nodereference.
In D6 I used argument : user: uid and if there is no arg, it uses the user id of the logged in user. This would return all of the content that was authored by the user.
I haven't been able to figure out how to do this in Views 3?
got it:
you first need to add a User relationship, then you will see new filters and contextual filters - one of which is "current user" or something like that
This five minute video shows how to do it, as well: http://nodeone.se/sv/node/684
With contextual filters you can also display the list as a tab on each user page (as shown in the screencast).
If you're interested in a list that always shows the current user's posts, you can use a standard filter instead – there is a "current user" filter available.
Edited: The original link is broken. I'm not sure which video it was, but it could be one of the following (which all deal with this topic).
https://vimeo.com/22276809 Video guide
https://vimeo.com/33588889 Exercise description
https://vimeo.com/33588956 Exercise solution
For drupal 7
Steps for doing as the above question are
Create a new content view and limit it to the content type you want.
Uncheck "Create a page" and check "Create a block." Select the format you want; I recommend an HTML list of linked titles. Click "Continue & edit."
Add a contextual filter for "Content: Author uid."
Under "When the filter value is not available," select "Provide a default value," and select "User ID from URL" from the dropdown. Because blocks don't understand contextual filters very well, the view won't work properly without this default value, and all posts of the given content type will show on all user pages (not just the user's own posts).
Under "When the filter value is available or a default is provided," check "Specify validation criteria" and select "Basic validation" as the validator. Select "Hide view" from the dropdown.
Save your view.
Assuming that you created a block display, the block will now be available on the Blocks page. Go there and open it.
Set your block to display on all user pages (/user/*) in the correct region. Save the block.
Your block should now appear on all user pages, showing the content written by each user.
Source

Resources