I've following smarty code:
<ul class="list-group">
{if $user_package_type_documents}
{assign var=cnt value=0}
{foreach from=$user_package_type_documents item='my_package_type_documents'}
{if $my_package_type_documents.pt_doc_file_iname != ""}
<li class="list-group-item test-series-item-ul-my-doc">
<div class="col-xs-7" style="">
<div class="test-series-heading-doc">
<span>{$cnt + 1})</span><span>{$my_package_type_documents.pt_doc_title}</span>
</div>
</div>
<div class="col-xs-5" style="">
<div class="vr-outter-div">
DOWNLOAD
</div>
</div>
</li>
{assign var=cnt value=$cnt+1}
{/if}
{/foreach}
{if $cnt == 0}
<li class="list-group-item test-series-item-ul-my-doc">
<div class="col-xs-7" style="">
<div class="test-series-heading-doc">
<span></span><span>Document Not Available.</span>
</div>
</div>
<div class="col-xs-5" style="">
<div class="vr-outter-div">
</div>
</div>
</li>
{/if}
{else}
<li class="list-group-item test-series-item-ul-my-doc">
<div class="col-xs-7" style="">
<div class="test-series-heading-doc">
<span></span><span>Document Not Available.</span>
</div>
</div>
<div class="col-xs-5" style="">
<div class="vr-outter-div">
</div>
</div>
</li>
{/if}
</ul>
In above code I want to print the values from 1 till the values come. For it I wrote the code {$cnt + 1} but still it's printing the value from 0. How to print this from 1? Also the initialization shouldn't be changed i.e. it should initialize to zero as it is now. Thank you.
In smarty you can't have whitespace in addition operation, so {$cnt + 1} won't work but {$cnt+1} should (you even do that later on).
Anyway if I understand what're trying to accomplish here, I think you can do it differently. First when you're looping over user_package_type_documents variable you can define loop name , so you'll be able to reference iteration number. That way you'll have those orderly numbers in your document list. In case your array is empty you can either set a condition checking it's count or add foreachelse clause that would replace that {if $cnt == 0}.
Related
I am using Laravel 8 to fetch data from database in the controller, which i am fetching successfully, i tried to view it using dd (in controller and in blade file as well) and received the array. Here is my code
This is my controller function
public function show($roomAd)
{
$showRoom = RoomAd::where('id',$roomAd)->get();
// dd($showRoom);
return view('seller/singleprod',compact('showRoom'));
}
here is my singleprod.balde.php file
<div class="wrapper row">
{{-- {{dd($showRoom)}} --}}
#if (!empty($showRoom))
<div class="preview col-md-6">
<div class="preview-pic tab-content">
<div class="" id=""><img src="{{ URL::to('/image') }}/{{ $showRoom->advert_image }}"
alt="room-ad-{{ $showRoom->id }}" /></div>
</div>
</div>
<div class="details col-md-6">
<h3 class="product-title">{{ $showRoom->advert_title }}</h3>
<p class="product-description">{{ $showRoom->advert_desc }}</p>
<h4 class="price">Rent: <span>${{ $showRoom->rent_with_duration }}</span></h4>
<h5 class="sizes">size:
<span class="size" data-toggle="tooltip" title="small">{{ $showRoom->room_size }}</span>
</h5>
<h5 class="area">Area:
<span class="color orange not-available" data-toggle="tooltip" title="Not In store"></span>
<span>{{ $showRoom->area }}</span>
<span class="color blue"></span>
</h5>
<div class="action">
<button class="add-to-cart btn btn-default" type="button">add to cart</button>
<button class="like btn btn-default" type="button"><span
class="fa fa-heart"></span></button>
</div>
</div>
#else
{{ 'Error' }}
#endif
</div>
My problem is i am not able to retrieve the data on specific div like $showRoom->advert_image, it shows the error
Exception Property [advert_image] does not exist on this collection instance.
don't use get() use first() if you are only getting single record.
$showRoom = RoomAd::where('id',$roomAd)->first();
or the better way is to use findOrFail()
$showRoom = RoomAd::findOrFail($roomAd);
hope this will solve your problem.
I am using getuikit's tab component ( https://getuikit.com/docs/tab ) in my Vue-App:
Now I see that every tab is active, if I use v-for to iterate through an array.
<ul class=" uk-tab-left" uk-tab>
<li v-for="test in tests" id="test">{{ test }}</li>
</ul>
In my codepen example you can see, that the class uk-active is always inserted automatically:
https://codepen.io/spqrinc/pen/Ydzbez
Is there a possibility to change this behavior?
You can add a empty li element before the loop to make sure the active class will not be added to the others.
Don't forget to add a key to the loop and bind the id.
<div id="app">
<div>
<div uk-grid>
<div class="uk-width-1-4#m">
<ul class=" uk-tab-left" data-uk-tab>
<li></li>
<li v-for="test in tests" :key="test" :id="test">
{{ test }}
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="app">
<div>
<div uk-grid>
<div class="uk-width-1-4#m">
<ul class=" uk-tab-left" data-uk-tab>
<template v-for="test in tests">
<li :key="test" :id="test">
{{ test }}
</li>
</template>
</ul>
</div>
</div>
</div>
</div>
What is my code failing to compile v-else used on element <div> without corresponding v-if. ?
In the <div class="card">, I want to conditionally render the input and also show either the editor-container or ql-editor.
<template>
<li
class="component composition">
<div
v-if="editable == true"
class="drag-handle">
<icon-drag-handle></icon-drag-handle>
</div>
<div class="card">
<input
v-if="component"
#keypress="setUnsaved(true); autosave($event, "title", editorTitleId)">
</input>
<div
v-if="editable==true"
#keypress="setUnsaved(true); autosave($event, "content", editorContentId)"
class="editor-container">
</div>
<div
v-else
v-html="compositionContentHTML"
class="ql-editor">
</div>
</div>
<div
v-if="editable == true"
class="component-actions">
<a #click.prevent.stop="deleteComponent">
<icon-times></icon-times>
</a>
</div>
</li>
</template>
I'm trying to click on 'Recommended' input tag of a 'Samsung' label. Please find the appropriate HTML code below.
`
<div class="card-wrapper">
<a class="card-focus has-shadow" href="/app/72292">
<div class="card-container">
<div class="card-logo">
<section class="card-info">
<div class="card-name">Samsung Push Service</div>
<div class="card-publisher hidden-xs">Samsung Push Service</div>
</section>
<div class="card-rating">
</div>
</a>
</div>
<div class="hidden-xs">
<div>
<div class="app-management">
<div class="checkbox ">
<div class="checkbox ">
<label>
<input id="Recommended-72292" class="" aria-disabled="false" value="Recommended" type="checkbox"/>
<span class="cr"/>
<span class="layer-label">Recommended</span>
</label>
</div>
<a href="/mdm">
</div>
</div>
</div>
</div>`
How to achieve this?
Your input seems to be a checkbox, not a button. Try changing its checked value instead of triggering a click:
document.getElementById('Recommended-72292').checked = true;
In selenium, click() method would do your job.
if ( !driver.findElement(By.id("Recommended-72292")).isSelected() )
{
driver.findElement(By.id("Recommended-72292")).click();
}
try following:
driver.findElement(By.cssSelector("div.checkbox input#Recommended-72292")).click();
I am looking at a way to add a class dynamically to aurelia template. I have to add an active class if the particular li is visible.
Example
<section id="jobsCategoryContainer" class="jobsCategoryContainer">
<h1>{{title}}</h1>
<div *ngFor = "#slide of jobCategorySlides; #i = index" id="job-category-slide_{{i}}" class="job-category-slide" [ngClass]="{active: initialCarouselIndex == i}">
<ul *ngFor = "#item of slide">
<li class="jobDetails" *ngFor="#job of item; #i = index">
<div>
<span id="{{job.name}}" class="jobName">{{ job.name }}</span>
</div>
<div>
<span>{{job.noOfJobs}}</span>
</div>
</li>
</ul>
</div>
<div>
Previous
Next
</div>
</section>
I want to add the active class on below code
<div class="phs-widget-body">
<div class="phs-carousel-inner">
<ul repeat.for = "slide of nearByJobSlides" class="phs-item phs-grid-row" >
<li repeat.for = "item of slide" class="phs-small-6">
<a href="javascript:void(0)">
<div class="phs-job-title">${item.title}</div>
<div class="phs-job-info">
<span class="phs-job-loacation">${item.location}</span>
<span class="phs-job-category">${item.category}</span>
</div>
</a>
</li>
</ul>
</div>
</div>
<div class="phs-widget-footer">
<a class="left" href="#phsNearbyJobs" role="button" data-slide="prev">
<i class="fa fa-angle-left"></i> Move to Previous
</a>
<ol class="phs-carousel-indicators">
<li repeat.for = "slide of nearByJobSlides" data-target="#phsNearbyJobs" data-slide-to="${$index}" class="" click.trigger="changeActiveClass()"></li>
</ol>
<a class="right" href="#phsNearbyJobs" role="button" data-slide="next">
Move to Next <i class="fa fa-angle-right"></i>
</a>
</div>
As well how do I pass an event Object on aurelia?
Just use interpolation
<div class="${ applyMyClass ? 'my-class' : '' }">
E.g.
<div class="${ carouselIndex == $index ? 'active' : '' }">
You don't need to do this with a click event, it's the same as ng2 (only less code!)