I'd like to remove some elements such as <footer> tag, menu row etc. on pages where body has unique classes like: 'shop_news_list' and 'shop_news'. The site is based on Smarty. I've tried to put those elements I want to delete in between something like this:
{if !($body_class == 'shop_news_list' || $body_class == 'shop_news')}
<footer>
<div class="innerfooter container row">
...
</div>
</footer>
{/if}
However it doesn't work or makes an element disappear from every page. Is there any other way I can do this or maybe you know how can I properly check if body has specific class. (I can not create new templates to use them on different pages).
Related
I have a class called event-manager in a wordpress php file in the plugins folder. They are using this class to style the elements, and I am using a custom css to over-write this. The problem is I cannot overwrite their css so I had to remove this class all-together.
I need to remove this class dynamically, removing manually every-time is pointless, because every-time the plugin gets updated the class comes back.
And here the html structure. The class appears on two different pages and on both pages the image alignment is different.
<!-- Home page -->
<div class="some-class">
<div class="some-more-class">
<div class="featured-image"> <!-- this image alignment is different -->
<div class="event-image"> <!-- this div is generated dynamically from the plugin -->
some link
</div>
</div>
</div>
</div>
<!-- Blog single -->
<div class="some-class">
<div class="some-more-class">
<div class="featured-img"> <!-- and image alignment is different -->
<div class="event-image"> <!-- this div is generated dynamically from the plugin -->
some link
</div>
</div>
</div>
</div>
To acheive this I used jquery .removeClass method.
$(function(){
$(".featured-img > div, .featured-image > div").removeClass("event-manager");
});
I also tried this
$(function(){
$(".featured-img > div").removeClass("event-image");
$(".featured-image > div").removeClass("event-image");
});
And this
var featuredimg = ['.featured-img > div','.featured-image > div'];
$(featuredimg.join()).removeClass('event-image');
On all these methods, the class seems to be removed, because its on two different pages, when I load the homepage.php for the first time, the class is removed but when I go to single.php, it did not remove automatically and when I refresh the page, the class removes. I am not sure why.
Can anyone help me.
Thanks.
In my opinions it is related with caching. Do you have any? If yes disable it to test if works without it. If no you can check on developer console if do you have any errors. Issue can be also with place the script like this (prefer at the end of the page).
I have a very simple page which displays a list of articles based on the category, which is present in the URL. The code is here:
{exp:channel:entries channel="news" limit="10" category="{segment_3}" disable="member_data|category_fields" paginate="bottom" orderby="date" dynamic="no"}
<a class="square_block" href="{url_title_path='news/article'}">
<div class="content_block">
<div class="news_block_headline">
{title}
</div>
<div class="news_block_text">
{exp:eehive_hacksaw words="30" append="..."}
{exp:remove_html}
{teaser}
{/exp:remove_html}
{/exp:eehive_hacksaw}
</div>
<div class="square_block_divider"></div>
<div class="news_block_date">
{entry_date format="%d/%m/%y"}
</div>
<div class="square_block_arrow"></div>
</div>
</a>
{/exp:channel:entries}
What I want to do is also display any articles from any child categories that may be related. How would I go about doing this? I have had a look at plugins like GWCode Categories and done some searching but most focus on simply getting child category names rather than actually pulling data from them.
OK so I cracked this using GWCode Categories. I had to use an embedded template due to PHP parsing issues with EE.
I created a template called widgets/news_specific_cats that looks almost identical to the code above, except the exp:channel:entries tag an embedded variable in it so it looks like this:
{exp:channel:entries channel="news" limit="10" category="{embed:childCategories}" disable="member_data|category_fields" paginate="bottom" orderby="date" dynamic="no"}
Then on the main page I have some PHP code to get a list of parent and child categories which are passed as the embedded variable like so:
<div style="display:none;">
{exp:gwcode_categories cat_id="{segment_3}"}
<?php
$childCategories .= "{cat_id}|";
?>
{/exp:gwcode_categories}
</div>
<?php
$childCategories = strip_tags($childCategories);
$childCategories = rtrim($childCategories, "|");
$childCategories = trim($childCategories);
?>
<div id="block_holder">
{embed="widgets/news_specific_cats" cats="<?php echo $childCategories; ?>"}
</div>
I have the GWCode block wrapped in a hidden div because for some reason GWCode insists on outputting data as a formatted list so I have to strip all that stuff out manually. Basically it just gets all the categories into a bar-delimited format that EE uses to denote selecting articles from multiple categories. I doubt this is the best way of accomplishing what I needed, but it works.
I added a field on the page content type called 'Page Title' (machine name field_machine_name).
I want to modify the markup for this field on the page. The default markup is something like this:
<div>
<div>
<div>FIELD VALUE</div>
</div>
</div>
I want it the markup to be
<div>
<div></div>
<div>FIELD VALUE</div>
<div></div>
</div>
I tried creating a file in my templates folder called field--field_page_title.tpl.php, but I'm not sure how to print the value of the field.
Check the documentation on field.tpl.php. Looks like the info you want will be in the $items array.
If you're not sure how that array is structured, the devel module will help you. Or you can just tell your template to dump the contents of the array onto the page (or into a log file) and find out what it looks like that way.
I've been looking around for some guide that could tell me how to make an existing menu editable when added in Concrete 5.
Here's the menu I'm using now, I'd like to be able to edit it in c5:
<div class="menu">
<ul>
<li><span>Hem</span></li>
<li><span>Om oss</span></li>
<li><span>Tjänster</span></li>
<li><span>Referenser</span></li>
<li><span> Kontakt</span></li>
</ul>
</div>
The links doesn't work at all in c5, so if anyone could help me a little that would be greatly appreciated!
Thanks!
One of the nice benefits of using any CMS is that it will automatically create the nav menu for you -- so that when users add new pages they automatically show up in the menu.
In Concrete5 specifically, the way you do this is with the "AutoNav" block. As with any block, this can be added to areas on your page, but since you generally want the nav menu to appear on EVERY page in the same place, you can also add the block directly in your template code.
So, for your menu (which is a one-level menu without a dropdown), replace your nav menu html with this code:
<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'none';
$nav->render('templates/header_menu');
?>
Now you will need to make a change to your CSS, because that code will generate HTML that is slightly different than what you have -- it looks more like this:
<ul class="nav-header">
<li>Hem</li>
<li>Om oss</li>
<li>Tjänster</li>
<li>Referenser</li>
<li>Kontakt</li>
</ul>
The differences are that there's no surrounding div (although you could leave that if you wanted by surrounding the php code above in the opening and closing div tags), there's no span around the nav items, and the class for a selected item is "nav-selected" instead of "current".
I am currently working on moving an expression engine site from one server to another and i noticed one issue i am having a hardtime debugging. When i upload an logo image all seems fine but the index.php page that the logo is displayed on it has this code
{embed="shared/head"}
<body class="{if segment_1 == ''}home{if:else}{segment_1}{/if}">
<div id="page" class="container">
<div class="span-22 prepend-1 append-1 last">
{embed="shared/masthead"}
{if logo !=''}
<div class="news_item_logo">
{organization}
{if link}<img src="{logo}" width="130" alt="{title}" />{if:else}
<img src="{logo}" width="130" alt="{title}" />{/if}
{/organization}
</div><!-- /.news_item_logo -->
<ul>
<li><h3>{title}</h3></li>
<li>{pub_date}</li>
{organization}
<li>{if link}{/if}{exp:php_text_format type="lowercase"}{if url_text != ''}{url_text}{if:else}{name}{/if}{if link}{/exp:php_text_format}{/if}</li>
{/organization}
<li>{if file}PDF{/if}{if web_link !='' AND file !=''} | {/if}{if web_link}HTML{/if}</li>
</ul>
{if:else}
<ul class="no_logo">
<li><h3>{title}</h3></li>
My question is this, I see curly brackets {} around if statements and i want to know first what language it is and second is there a way to debug like php print_r() because the code always goes to the else with the no_logo class and i want to know what and how i can test these variables "segment1" and "logo" and "organization" and "url" How do and where do i inspect these variables
You can gain some info about the given variables and values in the template using the following within your index.php:
<?php
$EE = get_instance();
var_dump($this->EE->TMPL);
?>
Note that PHP must be enabled in templates for that to work (see PHP in Templates).
{embed="shared/head"} - include the template head from the template group shared
<body class="{if segment_1 == ''}home{if:else}{segment_1}{/if}">
if the URI segment (EE/CI works with segments eg site.com/segment1/segment2/xxx) is empty (you are on the home page (www.site.com), then add no body class.
else, the user is on a page (in EE this is a template group), so set the class to be the name of the template group.
site.com/about-us produces class="about-us" - handy for page specific styling.
{embed="shared/masthead"} - include masthead
and so on.
The rest are conditionals to check if the variables have values, and outputs them
I presume you're using EE2.0, I'm not sure what {organizaton} is specifically, but that style:
{organization} {foo} {/organization}
in code igniter at least, is generally the equivalent of a foreach or looping through a recordset:
foreach($organizations as $organization) { // do something }
This is written in Expression Engine's own templating language.
You would have to check the documentation to see whether there is any way to debug variables.
Possibly helpful links:
Quick Reference Chart
PHP in Templates