I am trying to add some style to the current page to highlight it from the other pages style. But my code does not seem to work... all the numbers look the same!
<section id="pagination">
<nav>
<ul>
<li><a class='<%= "active" if (params[:page]).to_i == #myths.current_page %>'>
<!-- checking current page and params page -->
<%= #myths.current_page.to_i %> <br> <%= (params[:page]).to_i %> <br>
<%= will_paginate #myths, :inner_window => 1, :outer_window => 1, :previous_label => '← previous', :next_label => 'next →' %>
</a></li>
</ul>
</nav>
</section>
Any help is appreciated.
update
CSS
a.active{text-decoration:underline;}
Picture of the pagination the current page is 3 (the style is applied when i check for the current page).
I am not using any helper.
Here is the generated html
<section id="pagination">
<nav>
<ul>
<li><a class='active'>
3 <br> 3 <br>
<div class="pagination">
<ul>
<li class="prev previous_page ">
<a rel="prev" href="/tags/Justice?page=2">← previous</a>
</li>
<li><a rel="start" href="/tags/Justice?page=1">1</a></li>
<li><a rel="prev" href="/tags/Justice?page=2">2</a></li>
<li class="active">3</li>
<li><a rel="next" href="/tags/Justice?page=4">4</a></li>
<li>5</li>
<li class="next next_page ">
<a rel="next" href="/tags/Justice?page=4">next →</a>
</li>
</ul>
</div>
</a></li>
</nav>
</section>
this is the problem
<li class="active">3</li>
it should be
<li><a class="active" href="/tags/Justice?page=3">3</a></li>
for it to work. how to fix that?
since i am on page 3, 3 should be underlined the pagination should be like : <- previous 1 2 3 4 5 next ->
Consider reading the following wiki page. Just simplify your view:
<section id="pagination">
<%= will_paginate #myths, :inner_window => 1, :outer_window => 1, :previous_label =>
</section>
To add some special look and feel for the current page link, just set css style for the .current class. will_paginate will do the remaining staff for you and automatically add .current class to the current page link.
Update:
To make your particular case working, just change the css style to reflect the markup
li.active a {
text-decoration:underline;
}
Related
I have list of comments and I could append username of user, content and date to the list put when I tried to append the user image it shows null and I tried to append image from internet and also it shows null
<ul v-for="comment in comments" :key="comment">
<li class="comment-object">
<div class="image-container">
<img class="profile-pic" :src="'http://192.168.63.200:8000' + comment.author_image" v-on:change="currentUserImage" alt="profile picture"/>
</div>
<div class="comment-text">
<h2 class="username" style="color: #C2C3C4">{{comment.author}} <span class="muted">· {{comment.publish}}</span></h2>
<p class="comment">{{comment.content}} </p>
</div>
</li>
</ul>
await axios.post('/video/api/video/comments/create/', commentData)
.then(response => {
this.comments.unshift({ content: this.commentContent, author: this.$store.state.user.username, author_image: 'https://image.shutterstock.com/image-photo/surreal-image-african-elephant-wearing-260nw-1365289022.jpg', likes:0, publish:'now'})
})
The problem was in <img class="profile-pic" :src="'http://192.168.63.200:8000' + comment.author_image" v-on:change="currentUserImage" alt="profile picture"/>
I just removed the url http://192.168.63.200:8000 and it worked
I have a Typo3 Page with several wrappers and referenced elements on it.
I'm using flux-grid to create the content of the wrappers and then access it like this:
<v:variable.set name="contentElements" value="{flux:content.get(area:'content', render:'FALSE')}" />
<ul class="myClass">
<f:for each="{contentElements}" as="contentElement" iteration="iteration">
<li>
<h3 data-number="{iteration.cycle}">{contentElement.header}</h3>
<ul class="content" id="acc_{v:format.sanitizeString(string: '{contentElement.header}')}">
<li>
<v:content.render contentUids="{0:contentElement.uid}" />
</li>
</ul>
</li>
</f:for>
</ul>
Problem is, I always get the default language for contentElement.header instead of the translated version. The content itself that's been fetched via v:vcontent.render is shown in the correct language.
What am I doing wrong?
(Typo3 8.7.9)
I had to get the content first and then render it separately:
<f:for each="{contentElements}" as="contentElement" iteration="iteration">
<v:variable.set name="head" value="{v:content.get(contentUids: '{0: contentElement.uid}', render:'0')}" />
<v:variable.set name="theContent" value="{v:content.get(contentUids: '{0: head.0.records}', render:'0')}" />
<li>
<h3 data-number="{iteration.cycle}">{theContent.0.header}</h3>
<ul class="content" id="acc_{v:format.sanitizeString(string: '{theContent.0.header}')}">
<li>
<f:format.raw>{theContent.0.bodytext}</f:format.raw>
</li>
</ul>
</li>
</f:for>
Hope it helps someone...
I'm somewhat (6 months) new to MVC, and I like to use as little as code as possible, especially when it comes to reusable code, etc. I'm using Umbraco v7.2, and I have (3) tabs, all which use the same data type (custom grid v7).
The grid has (4) fields. Basically all (3) sections on my page are the same w/ the exception for the header and the object that is called (the dynamic object is what has the properties in them for the tab, which as I stated earlier, are the same).
How can I call a partial view and reuse the same code? The "foreach" is where I need to have this partial view called, as you can see it uses the same exact code w/ the exception of the object being iterated.
The "CurrentPage.XXXX" is what I need to pass, and I can have the same iterator
#foreach(var XXXX in CurrentPage.XXXX) <---- partial view
View:
#inherits Umbraco.Web.Mvc.UmbracoTemplatePage
#{
Layout = "Master.cshtml";
}
<article class="accordion-wrapper">
<div class="accordion-container accordion-contact">
Leadership Team
#foreach (var leadership in CurrentPage.leadershipTeam)
{
<section class="clearfix">
<div class="col-md-6 col-sm-6">
<ul>
<li>#leadership.contactName</li>
<li>#leadership.contactTitle</li>
</ul>
</div>
<aside class="col-md-6 col-sm-6">
<ul>
<li>#leadership.contactPhone</li>
<li>
#leadership.contactEmail
</li>
</ul>
</aside>
</section>
}
</div>
</article>
<article class="accordion-wrapper">
<div class="accordion-container accordion-contact">
The Lenders One Team
#foreach (var lenders in CurrentPage.lendersTeam)
{
<section class="clearfix">
<div class="col-md-6 col-sm-6">
<ul>
<li>#lenders.contactName</li>
<li>#lenders.contactTitle</li>
</ul>
</div>
<aside class="col-md-6 col-sm-6">
<ul>
<li>#lenders.contactPhone</li>
<li>
#lenders.contactEmail
</li>
</ul>
</aside>
</section>
}
</div>
</article>
.... another one here but omitted for brevity
And turn it into:
<article class="accordion-wrapper">
<div class="accordion-container accordion-contact">
Leadership Team
#Html.Partial( ?????? )
</div>
</article>
<article class="accordion-wrapper">
<div class="accordion-container accordion-contact">
The Lenders One Team
#Html.Partial( ?????? )
</div>
</article>
Partial ???
#foreach (var contact in ??????)
{
<section class="clearfix">
<div class="col-md-6 col-sm-6">
<ul>
<li>#contact.contactName</li>
<li>#contact.contactTitle</li>
</ul>
</div>
<aside class="col-md-6 col-sm-6">
<ul>
<li>#contact.contactPhone</li>
<li>
#contact.contactEmail
</li>
</ul>
</aside>
</section>
}
Appreciate it ;)
EDIT:
To clarify, I've used partial views before in Umbraco. The issue above is I have (3) different objects (grids in u7). How the grid works in Umbraco is you create a new data type, and define certain fields in that data type (textbox, media picker, etc). You can then add properties to document types (in this case I used the custom grid I created). Once a page is created, based off a document type, properties are inherited.
For the contact page, I needed (3) separate grids. However each grid has different data in them. Therefore this is (3) different JSON objects, which I iterate over. In the above code, the (3) JSON objects are:
leadershipTeam
lendersTeam
avisoryBoard (the one omitted for
brevity)
How can I pass (CurrentPage.JSONobjectHere) to the partial view, using only ONE partial view for all THREE sections?
Did something similar to this once.
Call your partial like this:
#Html.Partial("YourPartialName", (object)CurrentPage.lendersTeam)
And then use a dynamic as a model in your partial:
#model dynamic
#foreach (var contact in Model)
{
<section class="clearfix">
<div class="col-md-6 col-sm-6">
<ul>
<li>#contact.contactName</li>
<li>#contact.contactTitle</li>
</ul>
</div>
<aside class="col-md-6 col-sm-6">
<ul>
<li>#contact.contactPhone</li>
<li>
#contact.contactEmail
</li>
</ul>
</aside>
</section>
}
This is not too difficult. In the call to the partial, just use the name of the partial. This is the filename of the partial without the extention. The current "Model" will also be available in your partial without you have to pass something to the partial.
<article class="accordion-wrapper">
<div class="accordion-container accordion-contact">
Leadership Team
#Html.Partial("NameOfThePartialWithoutExtention")
</div>
</article>
If you inherit from UmbracoTemplatePage or the UmbracoViewPage, then you can use the model as if you were in the View itself.
#inherits Umbraco.Web.Mvc.UmbracoTemplatePage
#foreach (var contact in CurrentPage.Children)
{
<section class="clearfix">
<div class="col-md-6 col-sm-6">
<ul>
<li>#contact.contactName</li>
<li>#contact.contactTitle</li>
</ul>
</div>
</section>
}
Thanks Morten OC. Thumbs up. I was using NestedContent and calling Partial view to render IPublishedContent, but also wanted access to CurrentPage.
Simple cast to object first worked. To elaborate, here's some extra code in case someone needs the same -
Html.RenderPartial("~/Views/Partials/MyPartial.cshtml",
item, //for me this is an IPublishedContent
new ViewDataDictionary { { "CurrentPage", (object)CurrentPage } });
Then in my Partial, shortened for brevity -
#inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
#{
dynamic CurrentPage = ViewBag.CurrentPage;
}
<p>#CurrentPage.Name</p>
So my Model is IPublishedContent (since I was iterating through nested contents)
And then in ViewBag you'll have a reference to CurrentPage. I named it CurrentPage just so I could continue using CurrentPage as we typically do in Umbraco.
Cheers Morten H5YR
i've got a problem with combinations in my prestashop 1.6.0.9. Combinations just not showing in product page for example here - http://b-bservis.cz.webar.cz/home/8-jolly-fix.html there should be 3 combinations with different prices. I dont know what happend, but color picker and another (also default) combinations doesn't working too.
Can anybody help me please?
Thanks
Try activating the default theme, and navigate to the product page to see if the combinations show up. If they do show up, then you have a problem with your theme.
According to source file of his website, he's already using default-bootstrap theme.
Also according to the source file, product attributes are present, they just don't show up on product page.
<div id="attributes">
<div class="clearfix"></div>
<fieldset class="attribute_fieldset">
<label class="attribute_label">Balení </label>
<div class="attribute_list">
<ul id="color_to_pick_list" class="clearfix">
<li class="selected">
</li>
<li>
<a href="http://b-bservis.cz.webar.cz/zakladni-natery-penetracni/8-jolly-fix.html" id="color_26" name="" class="color_pick" title="">
</a>
</li>
<li>
<a href="http://b-bservis.cz.webar.cz/zakladni-natery-penetracni/8-jolly-fix.html" id="color_27" name="" class="color_pick" title="">
</a>
</li>
</ul>
<input type="hidden" class="color_pick_hidden" name="group_4" value="25" />
</div>
<!-- end attribute_list -->
</fieldset>
</div>
I had same problem with an earlier version of PrestaShop, after digging for hours I finally solved the issue.
You can check my post on PS forum and see if it helps.
I'm brand new to rails (and coding in general) so I've a quick question on retrieving images from a database
Running rails 3.2.8
I have a list of products, code, description, price and product_image in the database, The product images is stored as 123.jpg in the database and the image itself is stored in app/assets/images folder
In my view I have the following code
<div class="center_content">
<div class="center_title_bar">Latest Products</div>
<% #camera_catalogues.each do |camera_catalogue| %>
<div class="prod_box">
<div class="top_prod_box"></div>
<div class="center_prod_box">
<div class="product_title"><%= camera_catalogue.model_description %></div>
<div class="product_img"><%= link_to (image_tag camera_catalogue.product_image),camera_catalogue %></div>
<div class="prod_price"><span class="reduce">350$</span> <span class="price"><%=number_to_currency(camera_catalogue.price, :unit =>"€")%> </span></div>
</div>
<div class="bottom_prod_box"></div>
<div class="prod_details_tab">
<img src="assest/cart.gif" alt="" title="" border="0" class="left_bt" />
<img src="assest/favs.gif" alt="" title="" border="0" class="left_bt" />
<img src="assets/favorites.gif" alt="" title="" border="0" class="left_bt" />
details
</div>
</div>
Everything displays correctly except that the image is not retrieved from the database
which is this line
<div class="product_img"><%= link_to (image_tag camera_catalogue.product_image),camera_catalogue %></div>
Does the image in the database need to be saved with a different url. i.e. instead of 123.jpg it is saved as assets/123.jpg
or is there some other error in my code.
Help/advice greatly appreciated :)
Use it like this
<div class="product_img"><%= link_to (image_tag (camera_catalogue.product_image)),camera_catalogue %></div>
I guess it will work for you. You need not use 'assests/image_name'