I am trying to learn how to create my own module and I am stuck. I created text.module, text.install and text.info . It's just a basic module for inputing text.
So now I have the next scenario I input the text in textbox, it saves to a table in the database i can display it into a table like in this:
http://img33.imageshack.us/img33/5815/textyi.jpg
now my question is can you and how can you use function view so that in the picture "ttt" becomes a link so that you can see the title and text "ttt" ?
EDIT :
I figure out something i just need this :
in table I have 3 columns (test_id, title, text)
Now i use
$result = db_query("select title,text from {text} ");
now how can I turn title into a link . Let say that in row 1 col1 of title it stands house. How can i turn house into a link. Do i need to do sometning like this
$result= db_query ("select n.title, n.text form {text} n where n.title = :title", array (":title" => ???? ))
I think this is what you are looking for
<?php
l(t('Link text'), 'about-us', array('attributes' => array('class' => 'about-link')));
?>
http://api.drupal.org/api/drupal/includes%21common.inc/function/l/7 might help u..
Related
I'm a wordpress beginner.
I have some custom fields that contain multiple values, and I want to output them.
One custom field has multiple values (press review quotes for a show - reviewchart-review). But I also want it to output the corresponding value in the reviewchart-publication field (the name of the publication the press quote is from).
This is the code:
$post_meta_array = get_post_meta($post->ID, 'reviewchart-review');
$review_pub = get_post_meta($post->ID, 'reviewchart-publication');
foreach ($post_meta_array as $post_meta) {
echo $review_pub . '<blockquote><p>' . $post_meta . '</p></blockquote>';
}
This is the output:
Array
"Fresh and assured. This Restoration comedy has japes aplenty. Winning performances from Susannah Fielding and Geoffrey Streatfeild."
Array
“Simon Godwin’s production of George Farquhar’s play is one of the most consistently funny productions of a Restoration comedy you’re likely to see.”
Any help appreciated,
Thanks
I'm trying to translate a word on the WooCommerce checkout page.
My website is in the Dutch language, but they translated it poorly, so I want to use a different word.
What needs to be translated
It concerns the following line:
"Totaal €469,38 (Inclusief €79,38 Belasting)"
In English this says:
"Total €469,38 (Includes €79,38 tax)"
It's the line that sums up the total amount of the order. And I want to translate the word 'Belasting' to 'BTW'.
What I've tried
Checked out settings in WooCommerce
Installed the plugin Loco translator
Searched for the word with FTP (Adobe Dreamweaver)
As I couldn't find the word 'Belasting' anywhere, I did find the php-file with the element of the line.
This I found in the PHP-document wc-cart-functions.php:
if ( ! empty( $tax_string_array ) ) {
$value .= '<small class="includes_tax">' . sprintf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</small>';
}
And this is how the HTML part looks like:
<small class="includes_tax">
(inclusief
<span class="amount">€79,38</span>
Belasting)
</small>
My Question
I presume it does print the word 'Belasting' with the '%s' variable. However I am unable to find the content for that variable anywhere.
So can anybody help me out by finding how to translate this word?
Thanks for reading and I'd appreciate the help.
You can try using the gettext filter
Example
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Check out these related products', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
WooCommerce uses gettext for translations, as described here there are several methods of updating the translation, the easies of which is editing the file in woocommerce/i18n/languages/
The "Includes" part is translate-supported. i.e. you just need to add it to your translation file:
The translation file is in my case (danish): "../wp-content/languages/plugins/woocommerce-da_DK.po"
Open the file in your texteditor, e.g. Notepad++ and add these lines:
#: includes/class-wc-order.php:40 includes/wc-cart-functions.php:246
msgid "(Includes %s)"
msgstr "(Inkluderer %s)"
Now you need to compile the PO file to an MO file and you can use Poedit.
Just open the PO file and save it, it will create a new MO file that you can upload and replace the current MO file (path: "../wp-content/languages/plugins/")
So fare so good!
In regards to the "Tax" part. This is controlled in the admin module:
is there a way to split the title into 2 text? and split only from the first Hyphen(-)
Sample:
Input: Artist name - Song name
Output:
i found this but its not exactly what i need
Split a WordPress title into two lines
You can simply try this :
$array = explode('-', 'wordpress-title', 2);
Then echo $array[0]; // output wordpress
echo $array[1]; // output title
I have several John Jones with different names in a form. I submit the form to another program which uses "$checkednames = implode(', ', $_POST['raters']);". I echo $checkednames and see all the names but "count($checkednames)" is 1 and not the number of names. What could be wrong?
I appreciate any help.
You may seen the results by going to:
www.golfcourseratingassistant.org/ratecourse/
select Course name > Select Tee Box > Course Data ...select for all lists then "Save Data".
Selected data is only valid for the current session.
It will be 1 only, implode() returns a string containing a string representation of all the array elements in the same order, with the glue string between each element. See Manual
explode() will return an array of strings
So count() after explode() will give you the number of elements.
You can see the names because it is one string.
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo count($comma_separated);// Output will be 1
For explode():
$string= "lastname,email,phone";
$array= explode(",", $string);
echo count($array); //output will be 3
So i have a custom field that gives output as plain text in this format: dd. MM yy (09. October 2013). This is the loop that im using:
query_posts(array('category_name'=>'somecategory', 'posts_per_page'=>'5','paged' => get_query_var('paged')));
while (have_posts()) : the_post();
//stuff
the_field('mydate'); //the output is: dd. MM yy
//stuff
endwhile;
wp_reset_query();
//paginate_links code...
If i add this to query_posts:
'meta_key' => 'mydate', 'orderby'=>'mydate'
My posts get sorted only by day and year couse it seems it cant read the month couse its a string. And this kind of sorting is kinda usless. If the site was my i would change date format and it would be solved, but i am doing this site for someone and the designer already draw this date format in photoshop so it has to be this way. So how can i make this sort work properly?
Add below code before you query_posts:
add_filter('posts_where', 'filter_orderby');
function filter_orderby( $where = '' ) {
$where .= " AND $wpdb->postmeta.meta_key = 'mydate' ORDER BY mydate DESC";
return where;
}
hope it helps