I have to tweak the searchform from my wordpress theme, because it wont allows me to use accents such as é/è/à/ù etc, I dont to make them non-special chars and I thought about using Regex but cant figure out how/where to put the regex snippet.
Here is the page code :
do_action( 'mytheme_before_searchform' ); ?>
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<div class="row collapse">
<?php do_action( 'mytheme_searchform_top' ); ?>
<div class="small-11 columns">
<input type="text" value="" class="search-form" name="s" id="s" placeholder="SEARCH">
</div>
<?php do_action( 'mytheme_searchform_before_search_button' ); ?>
<?php do_action( 'mytheme_searchform_after_search_button' ); ?>
</div>
Any idea how I should proceed ?
Thanks
You have to put it on your theme's function file. In my case the form is redirected to the wp page /google-search (permalink), like this:
function add_rewrite_rules($aRules) {
$aNewRules = array('google-search/([^/]+)/?$' => 'google-search?pagename=page-google-search&q=$matches[1]');
$aRules = $aNewRules + $aRules;
return $aRules;
}
And i have registered the q var so wp allows it to be passed on the url.
Hope this help!
Related
Is it possible to adjust / remove entry fields on registration page?
Image:
In admin panel go to Customer > Custom Field
Here you can add any custom field you want. Just check Required before saving new field, and enable it. After that you will see it in your registration page.
Removing unnecessary field, like Fax
Open catalog/view/theme/default/template/account/register.tpl
Find following
<div class="form-group">
<label class="col-sm-2 control-label" for="input-fax"><?php echo $entry_fax; ?></label>
<div class="col-sm-10">
<input type="text" name="fax" value="<?php echo $fax; ?>" placeholder="<?php echo $entry_fax; ?>" id="input-fax" class="form-control" />
</div>
</div>
Replace it with following (using same name="fax" as above)
<input type="hidden" name="fax" value="" />
Removing necessary field, like Address
Do everything from the previous chapter
Open catalog/view/theme/default/template/account/register.tpl
Find following
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-address-1"><?php echo $entry_address_1; ?></label>
<div class="col-sm-10">
<input type="text" name="address_1" value="<?php echo $address_1; ?>" placeholder="<?php echo $entry_address_1; ?>" id="input-address-1" class="form-control" />
<?php if ($error_address_1) { ?>
<div class="text-danger"><?php echo $error_address_1; ?></div>
<?php } ?>
</div>
</div>
Replace it with following (using same name="fax" as above)
<input type="hidden" name="address_1" value="" />
Now open catalog/controller/account/register.php
Find private function validate() {, Inside of this function we can see all validations.
Look for
if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
$this->error['address_1'] = $this->language->get('error_address_1');
}
and remove (or comment) it.
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-telephone1">Confirm Telephone</label>
<div class="col-sm-10">
<input type="tel" name="telephone1" value="" placeholder="Confirm Telephone" id="input-telephone1" class="form-control" required/>
<?php if ($error_telephone1) { ?>
<div class="text-danger"><?php echo $error_telephone1; ?></div>
<?php } ?>
</div>
</div>
I am getting an error message even though I have already defined a variable in language and controller. Error message is given below:
errorNotice: Undefined variable: error_telephone1 in /home/chaarms/public_html/catalog/view/theme/default/template/account/register.tpl on line 85
in corresponding controller file, in your case catalog/controller/account/register.php you should define it:
$data['error_telephone1'] = "some code where from you want to get this info";
for example if you want to add some text code should be next:
$data['error_telephone1'] = $this->language->get('error_telephone1');
and in corresponding language file add:
$_['error_telephone1'] = 'Telephone error!!!';
that's all.
i create new template for j2.5,
i need to add many module only show on home,
now i need to show many module all page without home,
pleas see my code below :
<div class="row" style="margin-top:20px;">
<div class="col-xs-12 co-md-12">
<?php if($this->countModules('adsright')) : ?>
<div class="col-xs-12 col-md-2">
<jdoc:include type="modules" name="adsright" style="custom" />
</div>
<?php endif; ?>
<div class="col-xs-12 col-md-10">
<div class="content">
<jdoc:include type="message" />
<jdoc:include type="component" /> </div></div>
</div>
</div>
when add module to adsright position and unchecked home page,was not show on my content,
how can i solve that ?
please tell me full way for create position conditional.
thanks.
please give some clear description of your problem.
And if you want certain positions and div structure on home page and not require same on inner pages then you can set condition based on this code. I hope this will help.
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'Home page';
}
Hy all,
I'm trying to give users an confirmation message when they unsubscribe to an newsletter. But i'm only getting the confirmation message without the rest of the website.
Here's the url so you can see what's going on...
In the unsubscribe controller class i have this code to render the page:
$this->language->load('newsletter/unsubscribe');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->template = 'default/template/newsletter/newsletter.tpl';
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
My template file looks like this:
<div class="box">
<div class="box-heading">Uitschrijven</div>
<div class="box-content">
<div id="notification">
<div class="success" style="">
U bent succesvol uitgeschreven.
<img src="catalog/view/theme/metroshop/image/close.png" alt="" class="close">
</div>
</div>
</div>
</div>
When i look at the other's ( the product controller or the account, and google ) it says that this is the right way to render the page ( with the childs like that ). But as you can see, the children ( the rest of the site ) isn't renderd.
What did i miss? Why isn't this working?
Alright, i've figured it out. I could delete my question, but mayby does this help others in the future so i'm answering it...
My template file looked like this:
<div class="box">
<div class="box-heading">Uitschrijven</div>
<div class="box-content">
<div id="notification">
<div class="success" style="">
U bent succesvol uitgeschreven.
<img src="catalog/view/theme/metroshop/image/close.png" alt="" class="close">
</div>
</div>
</div>
</div>
That's only the content. But you also need to echo the header, footer and all that kind of stuff. So you've got to do something like thisedi:
<?php echo $header; ?>
<?php echo $column_left; ?>
<?php echo $column_right; ?>
<div id="content">
<?php echo $content_top; ?>
<h1 style="display: none;">
<?php echo $heading_title; ?>
</h1>
<div class="box">
<div class="box-heading">Uitschrijven</div>
<div class="box-content">
<div id="notification">
<div class="success" style="">
U bent succesvol uitgeschreven.
<img src="catalog/view/theme/metroshop/image/close.png" alt="" class="close">
</div>
</div>
</div>
</div>
<?php echo $content_bottom; ?>
</div>
<?php echo $footer; ?>
And that's working fine now. Hope that this help's somebody in the future.
I'm trying to create a teaser node template to display all Blog teasers.
For the page tpl I have page-blogs.tpl.php
For the Blog node tpl I have node-blog.tpl.php (This one is looping to display all the blog teasers)
Now how do I create a node template to surround the node teasers?
My URL for the page with all the blog teasers is: /blogs/eric
My URL for the page with an example blog entry is: /blogs/eric/test-blog-1
I need a node template that I can use for all the Blog pages.
I tried using node-blogs-teaser.tpl.php for the individual teaser nodes and node-blog.tpl.php for the outer blog node template, but that didn't work.
Here is what I have in my node-blog.tpl.php file:
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<div class="item">
<ul>
<?php print $picture ?>
<?php if ($page == 0): ?>
<?php endif; ?>
<div class="content clear-block">
<li class="title"><h4><?php print $title ?></h4></li>
<li class="photo"><img src="/<?php print $node->field_blog_image[0]['filepath']; ?>" /></li>
<li class="desc"><?php print $node->content['body']['#value']; ?></li>
<li class="link">
<?php if ($teaser): ?>
Read more | Audio/Video |
<?php endif; ?>
<?php print $submitted; ?>
</li>
<div class="clear"></div>
</div>
<div class="clear-block">
<div class="meta">
<?php if ($taxonomy): ?>
<div class="terms"><?php print $terms ?></div>
<?php endif;?>
</div>
</div>
</ul>
</div>
</div>
thanks
UPDATE: I added a page preprocessor function in template.php :
/**
* Override or insert PHPTemplate variables into the templates.
* These are the main outer templates such as page.tpl.php
*/
function phptemplate_preprocess_page(&$vars) {
// add template hints using path alias
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$vars['template_files'][] = $template_filename;
}
}
//----
}
Assuming your content type is called "blog", then node-blog.tpl.php will be used whenever a blog post needs to be displayed. The $teaser variable will be set to TRUE in node-blog.tpl.php if Drupal is wanting the teaser display, and the $page variable will be set to TRUE if the node is being shown in full page view (they will both be FALSE if the full node is being shown in a list of nodes). So you need to set up your node-blog.tpl.php to check for what type of display is being requested and return the HTML appropriate to the given type. The general setup of your node-blog.tpl.php should be along these lines:
if($teaser){
//return teaser html
}
else{
//return full node HTML
}
It's a little unclear to me from your question, but it sounds like you might have some sort of looping code in node-blog.tpl.php to iterate over the nodes on your site. You do NOT want to do this. Drupal does not work like Wordpress.
You don't mention how your list of teasers is being generated at /blogs/eric but I'd recommend using the Views module. If you use Views to generate the list of teasers then you'll be able to easily theme the list using Views' theming.
Edited since you added your example code
To stick arbitrary HTML at the top of ONLY the full node display of a blog page you could edit your node-blog.tpl.php to look something like this:
<?php if ($page): ?>
My arbitrary HTML here which will not show up in teasers and only at the top of full blog pages
<?php endif; ?>
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<div class="item">
<ul>
<?php print $picture ?>
<?php if ($page == 0): ?>
<?php endif; ?>
<div class="content clear-block">
<li class="title"><h4><?php print $title ?></h4></li>
<li class="photo"><img src="/<?php print $node->field_blog_image[0]['filepath']; ?>" /></li>
<li class="desc"><?php print $node->content['body']['#value']; ?></li>
<li class="link">
<?php if ($teaser): ?>
Read more | Audio/Video |
<?php endif; ?>
<?php print $submitted; ?>
</li>
<div class="clear"></div>
</div>
<div class="clear-block">
<div class="meta">
<?php if ($taxonomy): ?>
<div class="terms"><?php print $terms ?></div>
<?php endif;?>
</div>
</div>
</ul>
</div>
</div>
Edited since finding out you're using the Blog module
To display arbitrary HTML at the top of the listing of blog teasers just stick it at the top of page-blog.tpl.php