The print $content statement in page.tpl.php . I want to alter it but I can't figure out what/where is the source of the $content variable in page.tpl.php file.
I'd appreciate any help. Thanks.
the drupal version is 6,
This is the return value of menu_execute_active_handler(). You can't change it in Drupal 6. You need Drupal 7 hook_page_alter() for that. Now, preprocess helps a little, see http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/6
chx's answer is correct. This is just a longer explanation.
$content depends on the URL or more precisely the region that calls the variable.
The URL could be something like node/10, taxonomy/term/1, etc. Each of these paths is associated with menu entry which has a callback function that generates the value of $content.
Take a look at the API docs for more info. http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_content/6
The ConTemplate module might provide the sort of control over $content that you are looking for. http://drupal.org/project/contemplate
Related
I've searched how to do it a week, but haven't success and it's been a bottleneck in the work so, I decided to ask.
I put <h3><?php print t("strings translation"); ?></h3> in page.tpl.php and flush all caches and reload every languages available in the site.
And then I try to search for the string in /admin/config/regional/translate/i18n_string the options available are Fields, Node types, Menu, Taxonomy, Blocks.
But then I can't find the "strings translation" in /admin/config/regional/translate/translate.
I have read in drupal.org documentation but it seems like I'm missing something.
Could you please advice how to do it?
Here is the way:
1) Drupal should know that a string is 'not translated'. To make it aware of this, you need to visit the page having the string and change the language. Once you do, Drupal will be aware of all those strings on the page which are not translated to the language selected currently.
2) Go to translate page, search for the string, it should now appear there
Are you missing echo in your code?
<h3><?php echo t("strings translation"); ?></h3>
I am not clear what are you looking for. But Stringoverrides modeule may solve your problem. It can translate any string across the project. But, if the string is inside t() function.
I need to edit a template's header.php file and I want to check if it has a taxonomy named "store". If so, then I need to extract it's tag_ID.
When I edit the page (it's not a WordPress Page type) I can see these values in the admin url:
taxonomy=store&tag_ID=720
So I know there is a way but I'm having trouble getting any good results. I tried the
method detailed here to extract at least the tag_ID but I'm getting NULL:
$tag_id=get_query_var('tag_ID');
echo $tag_id; //NULL
Edit:
To be clear in regards to the tag_ID because it may be confusing, all I really want is to get the unique id of the requested page so I figure seeing first if it has a taxonomy named "store" and then getting the right one using the tag_id.
AS far as i understand your question, You should try this:-
$data = get_queried_object();
With this, you can get what page/post/taxonomy is being called.
Just print-out/var_dump this $data variable, you will get full object of page/post/taxonomy.
Hope this may help you.
As we all know the WordPress' feed url is www.mysite.com/feed.
I have edited the feed-rss2.php file to show thumbnails if a certain GET parameter is passed. See the code below:
<?php if($_GET['c'] == 'detailswiththumb') echo the_post_thumbnail( array(100,100) ); ?>
But when I open the feed address like this:
www.mysite.com/feed?c=detailswiththumb
The code doesn't work. Can the arguments be passed this way? Am I missing something? Please help.
Firstly, the function is get_the_post_thumbnail() not the_post_thumbnail().
Then, their is one more problem in your code, that you have to pass the post id to get its thumbnail (for more info see http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail).
So, first you will have to extract the post id from somewhere and then only you would be able to get the thumbnail. But, I think it would be very tough, so try giving up this thought, for it would take you a lot of time and no living being is going to access that path.
There were browser cache issues. Even with Google Chrome's incognito window. Had to test it with passing fake arguments like...
www.mysite.com/feed?c=detailswiththumb&fakearguments=123
...to clear the cache. And the code is fine.
Sorry for wasting your time guys.
the drupal is 6.
1, in drupal.everything's output is by a theme function or a template file.is this right. if right,then question 2.
2,in a module there is a hook_link and hook_menu, how they output? i can't find a theme function or a template file effect it. thank you.
eg:in book's module there is a book_link() defined. but i can't find there is a heme_book_link(),and in hook_theme there is no return of the book_link.
3 things that make understanding Drupal hooks:
They are just regular php functions.
Many times they don't return anything.
They are "called" by module_invoke_all() or module_invoke()
For Example: If module foo has a hook_dosomething() there is a function in foo.module that implements module_invoke_all('foo', 'dosomething')
The other way to think about it is that the hook "exteneds" a function someplace else, and anything that happens in the hook happens in the function that calls module_invoke_all() in it.
Not all hooks generate output. hook_menu() and hook_link(), for example, just return arrays with data that will be used by Drupal in some way (e.g. to register new paths in the system).
I searched far and wide to find a working solution to this but couldn't find it.
What I want to do is change the argument that is passed to the view because I want for pathauto cleaned taxonomy terms to work as an argument. I have a code that transforms cleaned term back to a original one, but cannot make the view use it.
I saw some people changing it in hook_preprocess_views_view(&$vars) but in my case (Views 2.11) has a argument in $vars instanced so many times that it's not the way.
Can anyone please help me change this argument?
There may be a better way but you could use views_embed_view() and set the arguments yourself
I have two ideas, either to add some custom php code to the view's argument's phpcode section that does something like this
$args[0] = 1;
return $args;
or try to use the function
hook_views_pre_view(&$view, &$display_id, &$args) {
// modify $args value here
}
didn't test them so don't know which will work.
I think hook_views_pre_view might help you do just that.