I'm fetching and displaying data from a database, but data that means "NO" is represented by a "(", while data that means "YES" is represented by an "X". When I'm displaying the data in the twig, how do I convert the "(" to a "NO" and the "X" to a "YES"?
Here's my twig.html file:
{% extends 'base.html.twig' %}
{% block body %}
<div class="container">
<div class="starter-template">
<h1><strong>{{ shrub.commonname }}</strong></h1>
<p>THE FOLLOWING IS DETAILED information about the species <strong>{{ shrub.botanicalname }}</strong> (common name <strong>{{ shrub.commonname }})</strong>.</p>
{% if shrub == "(" %}
value=="YES"
<table class="table table-striped">
<hr>
<tbody>
<tr>
<th>ph Preference</th>
<td>{{ shrub.phpreference }}</td>
</tr>
<tr>
<th>Borderline Hardy</th>
<td>{{ shrub.borderlinehardy }}</td>
</tr>
<tr>
<th>Tolerates Wet Soil</th>
<td>{{ shrub.wetsoil }}</td>
</tr>
<tr>
<th>Tolerates Moist Soil</th>
<td>{{ shrub.moistsoil }}</td>
</tr>
<tr>
<th>Prefers Peaty Soil</th>
<td>{{ shrub.peatysoil }}</td>
</tr>
<tr>
<th>Prefers Well-drained Soil</th>
<td>{{ shrub.welldrainedsoil }}</td>
</tr>
<tr>
<th>Tolerates Drought</th>
<td>{{ shrub.drought }}</td>
</tr>
<tr>
<th>Tolerates Clay Soil</th>
<td>{{ shrub.claysoil }}</td>
</tr>
<tr>
<th>Prefers Sandy Soil</th>
<td>{{ shrub.sandysoil }}</td>
</tr>
<tr>
<th>Prefers Loam Soil</th>
<td>{{ shrub.loamsoil }}</td>
</tr>
<tr>
<th>Tolerates Infertile Soil</th>
<td>{{ shrub.infertilesoil }}</td>
</tr>
<tr>
<th>Prefers Rich Soil</th>
<td>{{ shrub.richsoil }}</td>
</tr>
<tr>
<th>Tolerates Compacted Soil</th>
<td>{{ shrub.compactedsoil }}</td>
</tr>
<tr>
<th>Tolerates City Conditions</th>
<td>{{ shrub.cityconditions }}</td>
</tr>
<tr>
<th>Tolerates Pollution</th>
<td>{{ shrub.pollution }}</td>
</tr>
<tr>
<th>Tolerates Salt Conditions</th>
<td>{{ shrub.salt }}</td>
</tr>
<tr>
<th>Tolerates Windy Conditions</th>
<td>{{ shrub.windy }}</td>
</tr>
<tr>
<th>Prefers Shade</th>
<td>{{ shrub.shade }}</td>
</tr>
<tr>
<th>Prefers Part Shade</th>
<td>{{ shrub.partshade }}</td>
</tr>
<tr>
<th>Prefers Full Sun</th>
<td>{{ shrub.fullsun }}</td>
</tr>
</tbody>
</table>
{% endif %}
<ul>
<li>
Back to the list
</li>
<li>
Edit
</li>
<li>
{{ form_start(delete_form) }}
<input type="submit" value="Delete">
{{ form_end(delete_form) }}
</li>
</ul>
</div>
</div>
{% endblock %}
And my controller if that matters:
public function showAction(Shrubs $shrub)
{
$deleteForm = $this->createDeleteForm($shrub);
return $this->render('shrubs/show.html.twig', array(
'shrub' => $shrub,
'delete_form' => $deleteForm->createView(),
));
}
To set a twig variable based on some logic, you need to use something like this.
{% set value = '' %}
{% if '(' == shrub %}
{% set value = 'YES' %}
{% elseif 'X' == shrub %}
{% set value = 'NO' %}
{% endif %}
I used a twig extension, like someone suggested above:
public function getFilters()
{
return array(
new \Twig_SimpleFilter('x', array($this, 'booleanFilter')),
);
}
public function booleanFilter()
{
$x = "yes";
return $x;
}
Then the variable: {{ shrub.wetsoil | x}}
Related
I am newbie in laravel, i'm trying to show the table like image below
https://i.stack.imgur.com/l52Vo.jpg
#foreach($report_data as $index => $item)
<tbody class="table-content">
<tr>
<td>{{ $index+1 }}</td>
<td style="text-align:left;">{{ $item->customer_fullName }}</td>
<td>{{ $item->customer_phone }}</td>
<td>{{ $item->customer_detail_licensePlate }}</td>
<td>{{ $item->vehicle_brand_name }}</td>
<td>{{ $item->vehicle_model_name }}</td>
</tr>
</tbody>
#endforeach
but the output is like image below
https://i.stack.imgur.com/rSktI.png
Thanks!!
I would do it as so:
In the controller, select the customers eager loading the vehicles.
$customers = Customer::with('vehicles')->get();
return view('customers')->with('customers', $customers);
In the view:
<table>
#foreach($customers as $index => $customer)
<tr>
<td rowspan="$customer->vehicles->count()">
{{ $index+1 }}
</td>
<td rowspan="$customer->vehicles->count()">
{{ $customer->fullName }}
</td>
<td rowspan="$customer->vehicles->count()">
{{ $customer->phone }}
</td>
<td> {{$customer->vehicles[0]->licensePlate }} </td>
<td> {{$customer->vehicles[0]->brandName }} </td>
<td> {{$customer->vehicles[0]->modelName }} </td>
</tr>
#for($i=1;$i<$customer->vehicles->count())
<tr>
<td> {{$customer->vehicles[$i]->licensePlate }} </td>
<td> {{$customer->vehicles[$i]->brandName }} </td>
<td> {{$customer->vehicles[$i]->modelName }} </td>
</tr>
#endfor
#endforeach
</table>
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col">Customer</th>
<th scope="col">Licence Number</th>
<th scope="col">Brand</th>
<th scope="col">Brand Type</th>
</tr>
</thead>
<tbody>
#foreach($report_data as $index => $item)
<tbody class="table-content">
<tr>
<td>{{ $index+1 }}</td>
<td style="text-align:left;">{{ $item->customer_fullName }}</td>
<td>{{ $item->customer_phone }}</td>
<td>{{ $item->customer_detail_licensePlate }}</td>
<td>{{ $item->vehicle_brand_name }}</td>
<td>{{ $item->vehicle_model_name }}</td>
</tr>
</tbody>
#endforeach
</tbody>
use this CDN for Bootstrap style
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
You need not to iterate tbody everytime, just iterate <tr></tr> as below
<table>
<thead>
<tr>
<th>No</th>
<th>Customer</th>
<th>Phone</th>
<th>License Number</th>
<th>Brand</th>
<th>Brand Type</th>
</tr>
</thead>
<tbody class="table-content">
#foreach($report_data as $index => $item)
<tr>
<td>{{ $index+1 }}</td>
<td rowspan="2" style="text-align:left;">{{ $item->customer_fullName }}</td> //rowspan should be in some condition
<td>{{ $item->customer_phone }}</td>
<td>{{ $item->customer_detail_licensePlate }}</td>
<td>{{ $item->vehicle_brand_name }}</td>
<td>{{ $item->vehicle_model_name }}</td>
</tr>
#endforeach
</tbody>
</table>
I use Laravel to show data from Mysql to View by multi-queries.
Here is my Route:
Route::get('/procinstdetail','ProcDetailController#index');
And here is my controller:
use App\act_hi_taskinst;
use View;
class ProcDetailController extends Controller
{
private $act_hi_taskinst;
public function __construct(act_hi_taskinst $act_hi_taskinst) {
$this -> act_hi_taskinst = $act_hi_taskinst;
}
public function index(act_hi_taskinst $act_hi_taskinst, Request $request)
{
$procinstid = $request->get('id');
return View::make('datatrackingdetail')->with('data', $this->act_hi_taskinst->getData($procinstid));
}
}
And my model:
class act_hi_taskinst extends Model
{
public function getData($procinstid) {
$data = array();
$data['taskData'] = DB::select("SELECT NAME_, PRIORITY_, ASSIGNEE_, DUE_DATE_, START_TIME_, END_TIME_, PROC_DEF_ID_ FROM act_hi_taskinst WHERE PROC_INST_ID_ = $procinstid");
$data['varData'] = DB::select("SELECT NAME_, TEXT_ FROM act_hi_varinst WHERE PROC_INST_ID_ = $procinstid");
$data['subprocessData'] = DB::select("SELECT * FROM act_hi_procinst WHERE SUPER_PROCESS_INSTANCE_ID_ = $procinstid");
return $data;
}
}
Final is fetch data to view:
<body>
<h2>Task</h2>
<table border="1" cellspacing = "0" cellpadding = "3">
<tr>
<th>Name</th>
<th>Priority</th>
<th>Assignee</th>
<th>Due Date</th>
<th>Created</th>
<th>Completed</th>
</tr>
#if(isset($data))
#foreach($data as $processTaskDataValue)
<tr>
<td>{{ $processTaskDataValue -> NAME_ }}</td>
<td>{{ $processTaskDataValue -> PRIORITY_ }}</td>
<td>{{ $processTaskDataValue -> ASSIGNEE_ }}</td>
<td>{{ $processTaskDataValue -> DUE_DATE_ }}</td>
<td>{{ $processTaskDataValue -> START_TIME_ }}</td>
<td>{{ $processTaskDataValue -> END_TIME_ }}</td>
</tr>
#endforeach
#endif
</table>
<h2>Variable</h2>
<table border="1" cellspacing = "0" cellpadding = "3">
<tr>
<th>Name</th>
<th>Value</th>
</tr>
#if(isset($data))
#foreach($data as $processVarDataValue)
<tr>
<td>{{ $processVarDataValue -> NAME_ }}</td>
<td>{{ $processVarDataValue -> TEXT_ }}</td>
</tr>
#endforeach
#endif
</table>
<h2>Sub Process</h2>
<table border="1" cellspacing = "0" cellpadding = "3">
<tr>
<th>ID_</th>
<th>PROC_INST_ID_</th>
<th>BUSINESS_KEY_</th>
<th>PROC_DEF_ID_</th>
<th>START_TIME_</th>
<th>END_TIME_</th>
<th>DURATION_</th>
<th>START_USER_ID_</th>
<th>START_ACT_ID_</th>
<th>END_ACT_ID_</th>
<th>SUPER_PROCESS_INSTANCE_ID_</th>
<th>DELETE_REASON_</th>
<th>TENANT_ID_</th>
<th>NAME_</th>
</tr>
#if(isset($data))
#foreach($data as $subprocessDataValue)
<tr>
<td> {{$subprocessDataValue -> ID_ }}</td>
<td>{{ $subprocessDataValue -> PROC_INST_ID_ }}</td>
<td>{{ $subprocessDataValue -> BUSINESS_KEY_ }}</td>
<td>{{ $subprocessDataValue -> PROC_DEF_ID_ }}</td>
<td>{{ $subprocessDataValue -> START_TIME_ }}</td>
<td>{{ $subprocessDataValue -> END_TIME_ }}</td>
<td>{{ $subprocessDataValue -> DURATION_ }}</td>
<td>{{ $subprocessDataValue -> START_USER_ID_ }}</td>
<td>{{ $subprocessDataValue -> START_ACT_ID_ }}</td>
<td>{{ $subprocessDataValue -> END_ACT_ID_ }}</td>
<td>{{ $subprocessDataValue -> SUPER_PROCESS_INSTANCE_ID_ }}</td>
<td>{{ $subprocessDataValue -> DELETE_REASON_ }}</td>
<td>{{ $subprocessDataValue -> TENANT_ID_ }}</td>
<td>{{ $subprocessDataValue -> NAME_ }}</td>
</tr>
#endforeach
#endif
</table>
</body>
But I receive error:
Trying to get property 'NAME_' of non-object.
What's wrong with my code?
I'm new with Laravel so I really don't know how to fix it.
In your Model you are creating array with key taskData, varData and subprocessData and you forgot to use this key to your $data array while getting data
<body>
<h2>Task</h2>
<table border="1" cellspacing = "0" cellpadding = "3">
<tr>
<th>Name</th>
<th>Priority</th>
<th>Assignee</th>
<th>Due Date</th>
<th>Created</th>
<th>Completed</th>
</tr>
#if(isset($data))
#foreach($data['taskData'] as $processTaskDataValue)
<tr>
<td>{{ $processTaskDataValue->NAME_ }}</td>
<td>{{ $processTaskDataValue->PRIORITY_ }}</td>
<td>{{ $processTaskDataValue->ASSIGNEE_ }}</td>
<td>{{ $processTaskDataValue->DUE_DATE_ }}</td>
<td>{{ $processTaskDataValue->START_TIME_ }}</td>
<td>{{ $processTaskDataValue->END_TIME_ }}</td>
</tr>
#endforeach
#endif
</table>
<h2>Variable</h2>
<table border="1" cellspacing = "0" cellpadding = "3">
<tr>
<th>Name</th>
<th>Value</th>
</tr>
#if(isset($data))
#foreach($data['varData'] as $processVarDataValue)
<tr>
<td>{{ $processVarDataValue->NAME_ }}</td>
<td>{{ $processVarDataValue->TEXT_ }}</td>
</tr>
#endforeach
#endif
</table>
<h2>Sub Process</h2>
<table border="1" cellspacing = "0" cellpadding = "3">
<tr>
<th>ID_</th>
<th>PROC_INST_ID_</th>
<th>BUSINESS_KEY_</th>
<th>PROC_DEF_ID_</th>
<th>START_TIME_</th>
<th>END_TIME_</th>
<th>DURATION_</th>
<th>START_USER_ID_</th>
<th>START_ACT_ID_</th>
<th>END_ACT_ID_</th>
<th>SUPER_PROCESS_INSTANCE_ID_</th>
<th>DELETE_REASON_</th>
<th>TENANT_ID_</th>
<th>NAME_</th>
</tr>
#if(isset($data))
#foreach($data['subprocessData'] as $subprocessDataValue)
<tr>
<td><a href= "{{ url('/procinstdetail') }}?id={{
$subprocessDataValue -> ID_ }}&endtime={{ $subprocessDataValue ->
END_TIME_ }}"> {{$subprocessDataValue -> ID_ }}</a></td>
<td>{{ $subprocessDataValue->PROC_INST_ID_ }}</td>
<td>{{ $subprocessDataValue->BUSINESS_KEY_ }}</td>
<td>{{ $subprocessDataValue->PROC_DEF_ID_ }}</td>
<td>{{ $subprocessDataValue->START_TIME_ }}</td>
<td>{{ $subprocessDataValue->END_TIME_ }}</td>
<td>{{ $subprocessDataValue->DURATION_ }}</td>
<td>{{ $subprocessDataValue->START_USER_ID_ }}</td>
<td>{{ $subprocessDataValue->START_ACT_ID_ }}</td>
<td>{{ $subprocessDataValue->END_ACT_ID_ }}</td>
<td>{{ $subprocessDataValue->SUPER_PROCESS_INSTANCE_ID_ }}</td>
<td>{{ $subprocessDataValue->DELETE_REASON_ }}</td>
<td>{{ $subprocessDataValue->TENANT_ID_ }}</td>
<td>{{ $subprocessDataValue->NAME_ }}</td>
</tr>
#endforeach
#endif
</table>
</body>
DB::select() will return an Array. So call it's property accordingly.
small POC
Update: Also as per other answer, you are not iterating over elements of $data, not actual data that you get from DB::select.
I need help with a foreach loop in laravel. For some reason I need to have two rows instead of two tables (would have solved my problem) However, I have problems with it getting to work due to not knowing where to place my tags to get the right table structure.
Code:
<table class="minimalistBlack">
<tbody>
<tr>
<th>Etternavn</th>
<th>Navn</th>
<th>Posthylle</th>
<th>X</th>
<th>Etternavn</th>
<th>Navn</th>
<th>Posthylle</th>
</tr>
#foreach ($data as $mailbox)
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
<td></td>
#endforeach
#foreach ($data2 as $mailbox)
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
#endforeach
</tbody>
</table>
How can I combine the two foreach loops and and get the right table structure?
to achieve just that result you could do
foreach (array_combine($courses, $sections) as $course => $section)
but that only works for two arrays
or u can use two table and make feel as single table
<div class="row">
<div class="col-md-6 col-sm-6">
<table class="table table-striped">
#foreach ($data as $mailbox)
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
<td></td>
#endforeach
</table>
</div>
<div class="col-md-6 col-sm-6">
<table class="table table-striped">
#foreach ($data as $mailbox)
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
<td></td>
#endforeach
</table>
</div>
Assuming the $data and $data2 variables are Laravel collection instances, you can simply use $data = $data->concat($data2). Now $data will contain data of both variables. For a simple array, you can use $data += $data2;. This will merge $data & $data2 to $data. Then you can simply use:
...
#foreach ($data as $mailbox)
<tr>
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
</tr>
#endforeach
</tbody>
</table>
User array_merge function in controller like this
$array1 = array("john","ny");
$array2 = array("mitchel","ny");
$result = array_merge($a1,$a2);
if $data and $data2 have one, one row you can try like this.
#foreach ($data as $mailbox)
<tr>
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
<td></td>
</tr>
#endforeach
#foreach ($data2 as $mailbox)
<tr>
<td>{{ $mailbox->last_name }}</td>
<td>{{ $mailbox->first_name }}</td>
<td>{{ $mailbox->row }}{{ $mailbox->number }}</td>
</tr>
#endforeach
I cannot seem to put these into a scope.. And not sure if im doing something wrong...
HTML:
<div class="col-md-10 pull-md-left" style=" width:102%;">
<div class="row">
<span style="text-decoration:underline;">EC2 Instances</span> <span style="clear:both;">refresh</span>
<table class="table-striped" style="width:100%;border:1px solid gray;">
<thead>
<tr style="border-bottom:1px solid black; background-color:black; color:white;">
<th title="ID" style="width:20px;">#</th>
<th title="Customer Attached">Customer</th>
<th title="Instance Name">Name</th>
<th title="Instance ID">ID</th>
<th title="Instance Type">Type</th>
<th title="Instance Availability Zone">Zone</th>
<th title="This is Title">State</th>
<th title="Public DNS">WAN_DNS</th>
<th title="Public IP">WAN_IP</th>
<th title="What Instasnce Was Booted Up">Started</th>
<th title="Security Groups">Security</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="ec2 in servers">
<td>{{ $index + 1 }}</td>
<td>{{ customerID }}</td>
<td>{{ instancename }}</td>
<td>{{ ec2.instanceID }}</td>
<td>{{ ec2.instanceType }}</td>
<td>{{ ec2.instanceAvailabilityZone }}</td>
<td>{{ ec2.instanceState }}</td>
<td>{{ ec2.publicdns }}</td>
<td>{{ ec2.publicip }}</td>
<td>{{ ec2.startdate }}</td>
<td>{{ ec2.secgroup }}</td>
</tr>
<tr ng-show="!ec2.length">
<td colspan="11" style="text-align:center;">
<BR>
No Instances have been syncronized.
<BR>
<BR>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
CONTROLLER:
<script>
var app = angular.module('myApp', []);
app.controller('ec2instanceCtrl', function($scope, $http) {
console.log('a test');
$http.get("ec2instances.php")
.then(function (response) {
$scope.servers = JSON.parse(response.data);
//$scope.servers = response.data.records;
$scope.servers = results[0].ec2instance.map;
}
);
});
JSON:
{
"ec2instance": [{
"ID": 0,
"customerID": null,
"ec2.instancename": "domain1.host",
"ec2.instanceID": "i...",
"ec2.instanceType": "x3large",
"ec2.instanceAvailabilityZone": "us-east-1a",
"ec2.instanceState": "running",
"ec2.publicdns": "..com",
"ec2.publicip": "127.0.0.1",
"ec2.startdate": "11\/25\/2016 1:30AM",
"ec2.secgroup": "open.ports"
}, {
"ID": 1,
"customerID": 2,
"ec2.instancename": "server.com",
"ec2.instanceID": "i2",
"ec2.instanceType": "x5large",
"ec2.instanceAvailabilityZone": "us-east-2c",
"ec2.instanceState": "running",
"ec2.publicdns": ".com",
"ec2.publicip": "125.5.5.5",
"ec2.startdate": "11\/1\/15 1:00am",
"ec2.secgroup": "all"
}]
}
Now just trying to figure out the results and why it's not populating.... I am having no luck, is it because the JSON isnt properly formatted? Or am I not setting the scope correct?
Any help much appreciated!
Do $scope.servers = JSON.parse(response.data).ec2instance, then $scope.servers should be an array containing your servers.
Assuming the parsed data is ok (try console.log($scope.servers) after the JSON.parse line), use the following notation in your ng-repeat instead:
<tr ng-repeat="s in servers">
<td>{{ $index + 1 }}</td>
<td>{{ s.customerID }}</td>
<td>{{ s.instancename }}</td>
<td>{{ s['ec2.instanceID'] }}</td>
<td>{{ s['ec2.instanceType'] }}</td>
<td>{{ s['ec2.instanceAvailabilityZone'] }}</td>
<td>{{ s['ec2.instanceState'] }}</td>
<td>{{ s['ec2.publicdns'] }}</td>
<td>{{ s['ec2.publicip'] }}</td>
<td>{{ s['ec2.startdate'] }}</td>
<td>{{ s['ec2.secgroup'] }}</td>
</tr>
I have a table of employee's salary list. I wrap the employee id with an anchor tag to show salary history of each individual employees. The problem is when I print the table the link for individual salary history is also printed under the employee id.
Here is a screen shot print preview:
Blade
<div class="d-section col-md-12">
<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Position</th>
<th>Start Date</th>
<th>End Date</th>
<th>Worked</th>
<th>Basic</th>
<th>OT Rate</th>
<th>OT Hour</th>
<th>OT Amount</th>
<th>Basic Amount</th>
<th>Total</th>
<th>Signature</th>
<th>Finger</th>
</tr>
</thead>
<tbody>
#foreach($employees as $employee)
<tr>
<td>{{ $employee->eid }}</td>
<td>{{ $employee->name }}</td>
<td>{{ $employee->designation }}</td>
<td>{{ $employee->start }}</td>
<td>{{ $employee->end }}</td>
<td>{{ $employee->worked }}</td>
<td>{{ $employee->basic }}</td>
<td>{{ $employee->ot_rate }}</td>
<td>{{ $employee->ot_hour }}</td>
<td>{{ $employee->ot_amount }}</td>
<td>{{ $employee->basic_amount }}</td>
<td>{{ $employee->ot_amount + $employee->basic_amount }}</td>
<td></td>
<td>
{!! Form::open(['action'=>['SalaryController#destroy',$employee->id],'class'=>'no-print','method'=>'delete','onsubmit'=>'return deleteConfirm()']) !!}
{!! Form::submit('X',['class'=>'element btnn btn-danger']) !!}
<br/>
<span class="glyphicon glyphicon-edit"></span>
<br/>
<span class="glyphicon glyphicon-usd"></span>
{!! Form::close() !!}
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
Why not just create a CSS class for your anchors and hide them using that class?
foo
foo
And in your CSS:
.only-print{
display:none;
}
#media print{
a.hiddenTab {
display:none;
}
.only-print{
display:block;
}
}
All the anchors you'd want to hide would just use class="hiddenTab".
If you want to hide all a tags which have href set, you can do this:
a[href] { display: none; }