Translate custom button - wordpress

I need translated line of custom button in a code, but its not working my solution.
This is the line in file which I need translate (line 13, name of file: add-to-quote-button.php)
Quick Quote
There is my solution which is not working:
My solution
Additional informations:
name of my translated file: yith-woocommerce-request-a-quote-cs_CZ.mo
file location: plugins/woocommerce request a quote v1.6.1/templates/add-to-quote-button.php

There are two ways to do this.
One is a bit hacky and might get you into trouble if some huge change happens to woocommerce and other one is using CSS.
You could override that file in your child theme if you have one. if not you can do so in your parent theme.
Inside your theme folder create new folder 'woocommerce' and within woocommerce create 'templates' within that folder create file add-to-quote-button.php and copy whole content of the original file into this one and update that text.
Now that should overwrite woocommerce plugin file.
CSS Way would be to find class that's on that button - I'll name it 'someQuoteButton' just so I can give you an example.
.someQuoteButton {
font-size:0;
}
.someQuoteButton:after {
content: 'Some Content you Want';
font-size: 16px; // or any you need there
}

So you want to translate "Quick Quote" text in that line of code?
Try it like this:
<?php _e( 'Quick Quote', 'yith-woocommerce-request-a-quote') ?>

Related

Drupal basic page doesn’t seem to use page.tpl.php

Title says it really. Basic pages created in Drupal don’t seem to use the page.tpl.php file as a template.
If I edit the html.tpl.php file, those changes apply to every page, and it causes errors when I load a basic page.
I have also tried to copy the page.tpl.php file and name it page—basic-page.tpl.php to no avail.
Any idea what’s going on?
Also, how do I go about changing the page_top variable to include more content?
Lastly, the default page.tpl.php file has $page variables and things like $page_top and the like.
How would I call the title from the page only and the body text of a page only?
I’m using Drupal 7 and a custom sub theme.
The aforementioned files are in the template folder of the theme and I did clear caches when I added them.
Add $conf['theme_debug'] = TRUE; in settings.php and clear cache, reload page and check view source.
It will display the template file suggestions.
page.tpl.php file common for all pages. Just print anything to the tpl and run any node of basic page as well as other content type page and check if its working or not. If page.tpl.php not working for basic page only, then check your template.php file.
For print a page title just need to use following code:
<?php print $title; ?>
For print body text you need to use following:
<?php print render($page['content']); ?>
This may depend on the theme you are using. But I guess you are actually meaning page--page.tpl.php (double dashes). Which will be taken into account after you added the following snippet to your theme's template.php. Replace MYTHEME with your theme's machine name.
function MYTHEME_preprocess_page(&$variables) {
if (isset($variables['node']->type)) {
// If the content type's machine name is "my_machine_name" the file
// name will be "page--my-machine-name.tpl.php".
$variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type; // (double underscores)
}
}
See Template (theme hook) suggestions, where I also got above snippet from.
active theme debug for inspecting the template source and you get a different suggestions to user it (just avoid using node/nid).
commend drush to enable theme debug drush vset theme_debug 1

Connect WordPress Customizer CSS to style.css

Any CSS the customizer generates will be written directly into the head section.
The customizer API uses the wp_head hook for that.
I would like to take hold of this CSS somehow and connect it to style.css.
What I want to do is the following:
The Customizer spits out a class .red {color:red;}
I'd like to grab this information and transfer it into my style.css somehow.
Ideally the Customizer CSS would be inserted at the beginning of my style.css
EDIT Just to clarify: By "Customizer CSS" I am referring to CSS information generated by a color picker control for example. Not the CSS from that "Custom CSS" input field – this one I can just copy and paste into my style.css
One idea is to save the customizer CSS output not in the head section via wp_head but somewhere else, into a file for example.
How can I do that?
Is there a hook for that, is it even possible and does it make sense?
This is just one idea of mine – I am open to completely different approaches as well.
I think writing into a file directly is not a good idea at all. Because next time the value is changed, the previous written CSS would be unnecessary. Dynamic values should be changeable. As you write the output value into the file as suggested, the previous generated value will always be there which is redundant.
The best approach would be using wp_add_inline_style Refer here.
Use the following method to add the CSS to the refereed file:
function my_styles_method() {
$color = get_theme_mod( 'color-picker-control' ); //E.g. #FF0000
$custom_css = "
.mycolor{
background: sachet;
}";
wp_add_inline_style( 'main-style', $custom_css );
}
add_action( 'wp_enqueue_scripts', 'my_styles_method' );

Wordpress / OptionTree reference in css

I use this plugin to dynamically change the CSS in a user friendly way within the WordPress backend:
http://wordpress.org/extend/plugins/option-tree/
I set it up, and appended it to the theme (not a plugin anymore) - this works.
What I don't get is that those inputs get actually changed. So I set up a input field where the user can add a hexadecimalcode(colorpicker) to change the background, or even the font color.
How do I get this information to change in my CSS? I tried:
body {
{{custom_background_css}}
background-color: {{custom_background_css|background-color}};
}
where custom_background_css the id of this input field is. but nothing changes. I also read the documentation but I don't get it...
To adjust theme options for CSS, you'll have to include the CSS in your header, or write a .php file that generates the CSS you want, and link to that. But maybe the easiest way is to hook wp_head from functions.php, and write the code directly there. See below for a schematic example to add to your functions.php
// this is the hooked function
function add_css() {
echo "dynamically generated CSS here";
}
// Add your wp_head hooks
add_action('wp_head', 'add_css', 5);

How to hide title from page node Drupal

I'm trying to remove the title of a page node on Drupal. I have this page:
And I want it to look like this:
As you can see, I want the title to be removed, but only for taxonomy terms. If I try to erase it using CSS, I erase al page-titles, so I wanted to use this module, that allows administrators to auto-generate node titles and hide it.
I go to structure -> type content -> my type content, and edit it. I activate the module, and I want to auto-generate titles depending on the node category. I think it should look like this, but it doesn't work...
Any ideas why?
EDIT: Sorry, I forgot to say: yes, when I activate the module, use it, and select the category as the auto-generated title, it works. But it doesn't hide the title...
It also launches this mistake:
Use Exclude Node Title module.
https://drupal.org/project/exclude_node_title
Setting for this module:
Click on Module->Exclude node title->configure
Home » Administration » Configuration » Content authoring
Select All nodes from Basic Page
Check Full Content for hide title from all cms page except home page
Check Teaser for hide title from home page.
If you want to remove the title, you should look into overriding the page and node templates.
page.tpl.php and node.tpl.php
All you need to do is click "View Source" on both of those and copy them to your theme folder. From there you can modify both as required.
From what I can gather, you'll want to remove the print $title from your node.tpl.php.
Have the similar issue before, as far as I remember, I just added some if statement to the code:
<?php if (blah-blah-blah): ?>
<h2> <?php echo $title; ?> </h2>
<?php endif; ?>
Hope, it'll give you a clue.
Some other thoughts: you can make an if statement or rewrite it not only in page.tpl.php but create some specific page-node-type.tpl.php file and overwrite only its $title, or you can try to customize page's output via Views/Panels modules as well.
Also, could you please make more clear, what title do you want to remove? Page title or node title? And it should be removed only when you are looking nodes associated with some taxonomy term (in other words, when you are on /taxonomy/term/n page), am I right?
By using the Context module, you can add classes to the body so you can target just the taxonomy pages in CSS.
Using Context module to set body classes
Sorry guys, it was as easy as hide title tag on "manage presentation"...
You are all right on your responses, but they were not exactly what I needed... thanks!
Use Exclude Node Title module.
https://drupal.org/project/exclude_node_title
another nice solution for specific nodes, is to use the standard $title_prefix/suffix vars, which should be implemented by every theme. using the standard class element-invisible in page preprocess ..
like:
/**
* Implements hook_preprocess_page().
*/
function YOUR_THEME_preprocess_page(&$variables) {
if (isset($variables['node']) && $variables['node']->nid == 1) {
$variables['title_prefix'] = array('#markup' => '<div class="element-invisible">');
$variables['title_suffix'] = array('#markup' => '</div>');
}
}
Every page should contain a heading.
You should always maintain a structured hierarchy of headings within any web page. You should never have a blank heading or even hide it with display:none;. Hiding any content which isn’t viewable by your visitors but is by search engines is against Google’s guidelines as your intention is to only manipulate search engine results by including it. Restyle a H1 so it fits into your design is the best option.
If you still have to hide it then a better option would be to either create a template for that node, content type or page and simply not print the heading.
Or if you want to use CSS then use position:absolute so the heading doesn’t use any space where it is located in the page and text-indent:-9999px; so the text is moved off the screen and no longer visible but at least can be read by screen readers and search engines.
This is how I did it, Switch statement
// Get the name of node
$node_name = node_type_get_name($node);
// Then just add the content types you wish to exclude by overwriting the // $title object with an empty string
switch ($node_name) {
case 'Home page':
$title = '' ;
break;
case 'Event':
$title = '';
break;
case 'Offer':
$title = '';
break;
}

How do I remove a colon from a label?

I've Googled for an answer, but most posts seem to be talking about labels within forms. I have custom fields set up in content block in Drupal 7. When I show the titles (labels) of those custom fields, it adds a colon after after the title. Is there a way to remove them?
You need to override field.tpl.php to do this (the colon is hard coded into that template file).
Create field.tpl.php anywhere in your theme folder, copy the code from the above link into it, tweak it (remove the colon etc), then clear your caches: all will be well!
Override field.tpl.php and add a span (with a class) around the colon, then use CSS to hide the colon. This gives you flexibility in deciding when to hide the colon. For labels set to above you may wish to hide the colon and for labels set to inline you might want to keep the colon.
Example:
In your Drupal installation folder, look in modules/field/theme and copy field.tpl.php file to your theme.
For D7, edit field.tpl.php and change <?php print $label ?>: to <?php print $label ?><span class="field-label-colon">: </span>
In your theme CSS style sheet add .field-label-colon{display: none;} or to only hide label for label above .field-label-above .field-label-colon{display: none;}
I just want to add my grain of salt to this topic. I have been trying to do this a few time and I usually end up creating a custom template file for each field I want to remove the column, which is not a good solution in my opinion, because the presence of the label is design dependant; in a good MVC structure, this feature should be controlled by the View (CSS), not the Model (PHP template).
There is what I did this time:
Copy the file modules/field/theme/field.tpl.php into your theme.
Add a span around the column:
<?php print $label ?><span class="label-suffix">: </span>
Add CSS directives to remove the column where your design required to remove it:
#sidebar-first .label-suffix {
display: none;
}

Resources