PHP template (.tpl) how to exclude directories - php

I'm using a PHP autoindex script which utilizes the template (.tpl) below. I would like to open files only in a new tab. I've tried adding target="_blank" to line 3 below, but this doesn't differentiate between files or directories and both open in a new tab. I want to exclude directories from opening.
<tr class="{file:tr_class}">
<td class="padded_row">
<a class="autoindex_a" href="{file:link}">
{if:icon_path}<img width="16" height="16" alt="[{file:file_ext}]" src="{file:icon}" />{end if:icon_path}
{file:filename} {file:thumbnail}
</a>{file:new_icon}{file:md5_link}{file:delete_link}{file:rename_link}{file:edit_description_link}{file:ftp_upload_link}
</td>
{if:download_count}
<td class="cell_right">
{file:downloads}
</td>
{end if:download_count}
<td class="cell_right">
{file:size}
</td>
<!--<td class="cell_right">
{file:date}
</td> -->
{if:description_file}
<td class="padded_row">
{file:description}
</td>
{end if:description_file}
</tr>
I'm wondering if there is a way to check before opening the link like an "if statement". If it is a directory or file and then "do something"...however I'm not skilled in this area.
thanks for your help

Related

Yii2 Swiftmailer can't send image and font awesome icons

Mu Controller Code:
if ($model->load(Yii::$app->request->post())) {
$data = $this->renderPartial('receivers/contact_form_output_quick_query', [
'model' => $model,
'formData' => $_REQUEST], true);
$receiver_message = $this->renderPartial('receivers/receiver_message_quick_query',['data' => $data]);
$message = Yii::$app->mailer->compose();
$message->setFrom('info#company.com')
->setTo('info#company.com')
->setSubject('Subject Of email')
->setHtmlBody($data)
->send();
$message = Yii::$app->mailer->compose();
$message->setFrom('info#company.com')
->setTo($model->email)
->setSubject('Reply: Online Query')
->setHtmlBody($receiver_message)
->send();
Yii::$app->session->setFlash('success', 'Congratulations! Your message has been successfully Sent.');
}
Will some one tells me what is the main reason that image and Font Awesome icons are not sending properly?
My receiver message partial view goes here:
<div>
<table style="width: 600px;">
<tr>
<td>Thanks for your interest in our services. We have received your online query.</td>
</tr>
<tr>
<td>Thanks again for contacting us.</td>
</tr>
<tr>
<td style="height: 5px;"></td>
</tr>
<tr>
<td>(It may take some time depending upon the number of queries in the pipeline. We appreciate your cooperation in this regard.)</td>
</tr>
<tr>
<td>Regards!</td>
</tr>
</table>
<?= $this->render('signature'); ?>
<table>
<tr>
<td><strong style="font-size:16px;">Query Details that we received:</strong></td>
</tr>
<tr>
<td><?= $data; ?></td>
</tr>
</table>
</div>
The above is the render partial view for the receiver message:
My signature partial view is:
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<table>
<tr>
<td colspan="3">
<img src="<?= $this->theme->baseUrl?>/images/email_signature.png">
</td>
</tr>
<tr>
<td style="height: 30px;"></td>
</tr>
<tr>
<td>+123456778</td>
<td colspan="2"> | +123456778</td>
</tr>
<tr>
<td>http://www.example.com</td>
<td>| info#company.com </td>
<td>| <b>Skype:</b> skypeid</td>
</tr>
<tr>
<td><a target="_blank" href="https://www.linkedin.com"><i class="fa fa-linkedin"></i> Linked In | </a></td>
<td><a target="_blank" href="https://www.facebook.com"><i class="fa fa-facebook"></i> Facebook | </a></td>
<td><a target="_blank" href="https://twitter.com"><i class="fa fa-twitter"></i> https://www.twitter.com</a></td>
</tr>
The above is the render partial view for signature containing image and font awesome icons main problem is in this file.
Images
$this->theme->baseUrl will return path to theme, but without domain and scheme part (for example it will return /themes/my-theme). When you're generating URLs for mailing, you need to full URL with scheme and domain - you should generate URLs like this:
<img src="<?= Yii::$app->request->getHostInfo() . $this->theme->getBaseUrl() ?>/images/email_signature.png">
Font Awesome Icons
I have a bad news for you - many clients (especially webmails) does not support webfonts, so you will not be able to use Font Awesome icons in this way. Support for SVG is even worse, so this is not a solution either. You should probably stick to good old PNGs as icons.
Unfortunately working with mailing is like a time travel - you should build your emails in the same way you created your websites 10-20 years ago. Forget about fancy CSS3 features - the most bulletproof templates are still built using tables with inline CSS everywhere...
Not every mail client supports webfonts. So probably best for you is to download it as images, save it in your public assets folder and invoke it with img element tag.
if I am not wrong you need to use embed() or attach() for showing inline images in the email.
$Imageid = $message->attach(Swift_Attachment::fromPath('path/to/image')
->setDisposition('inline'));
and then use the $cid for showing the image inside the email text where ever you are assigning the text for the email
<img src="' . $Imageid . '" alt="Image" />'

How to selector a code of some of the same code in WP Web Scraper?

I use WP Web Scraper to take the title from the following link :
http://lpse.acehtenggarakab.go.id/eproc/lelang/view/1316330
The title is: PENGAWASAN/SUPERVISI KEGIATAN FISIK TAHUN 2016
The title is inside a <td> html tag with an attribute class="horizLine" (It is located on the second line (<tr> html tag) of this html <table> that contains 68 lines).
My WP Web Scraper shorthcode is:
[wpws url="http://lpse.dephub.go.id/eproc/lelang/view/33737114" selector=".horizLine"]
But It doesn't work.
My Question:
How can I target this title in the selector attribute of my shortcode, while others ignored?
I think you need to add some more elements in your shortcode selector attribute, because the displayed html source is:
<tr>
<td width="150" class="TitleLeft">Kode Lelang</td>
<td colspan="3" class="horizLine"><b>1316330</b></td>
</tr>
<tr>
<td class="TitleLeft">Nama Lelang </td>
<td colspan="3" class="horizLine">
<b>
<strong>PENGAWASAN/SUPERVISI KEGIATAN FISIK TAHUN 2016</strong>
</b>
</td>
</tr>
<tr> …
Here is the solution to target the title is selector="tr:nth-child(2) td.horizLine b strong":
[wpws url="http://lpse.dephub.go.id/eproc/lelang/view/33737114" selector="tr:nth-child(2) td.horizLine b strong"]
With :nth-child(2) I am targeting the 2nd <tr> html element.

Opening a menu item using iframe

When I click on a menu item is it possible to open the link from the iframe? I have some knowledge of php.
</tr>
<tr align="left" height="25" bgcolor="#B3BBB5">
<td class="textmenu">
Home |
About Us |
Contact Us
</td>
</tr>
<tr align="center">
<td width="100%"><div style="height:510px;">
<iframe src="Home.php" width="100%" name="scs_body" frameborder="no" style="height:500px;" ></iframe>
</div></td>
You can. But please don't do it. It's very outdated and bad design IMO.
Target your <iframe> name on the anchors you want to load:
Home

How to Override NyroModal Wrapper?

How can I Override NyroModal Wrapper.
I dont want to override the css class, we need the ability TO ADD our divs instead of the native WRAPPER div.
On GitHub i found 2 functions: beforeShowCont and filledContent, but i dont know how to override the wrapper using these functions.
And I also found this article on code google, and this is exactly what i want to develop, but it doesnt say how.
<table class="ctools-modal-content">
<tr>
<td class="popups-tl popups-border"></td>
<td class="popups-t popups-border"></td>
<td class="popups-tr popups-border"></td>
</tr>
<tr>
<td class="popups-cl popups-border"></td>
<td class="popups-c">
<div class="popups-container">
<div class="popups-title">
<span id="modal-title" class="modal-title"></span>
<span class="popups-close"><a class="close" href="#">Close</a></span>
<div class="clear-block"></div>
</div>
<div id="modal-content" class="modal-content">HERE WOULD .wrapper OR #nyroModalContent GO</div>
<div class="popups-buttons"></div>
<div class="popups-footer"></div>
</div>
</td>
<td class="popups-cr popups-border"></td>
</tr>
<tr>
<td class="popups-bl popups-border"></td>
<td class="popups-b popups-border"></td>
<td class="popups-br popups-border"></td>
</tr>
</table>
I refer the nyroModal code from here
If you want to override the wrapper class of it, you can do it by following way.
select the main container of the nyroModal.
add the new style for its wrapper.
i.e.
div#nyroModalFull div.wrapper{ /* your own style*/ }
load your own stylesheet after the nyroModal style
I hope this will work for you

IF/ELSE for header.tpl

I am working on a site that isn't SEO friendly. Specifically, the header.tpl is inserted automatically into every page, with no option to change it based on the content of the page. I.e., whether category = Bathroom or category = Kitchen, etc.
So I need an if/else command, but having trouble figuring it out in this instance, plus the change that goes along with it.
The code on the portfolio_category.php page is as follows, and what needs to change based on vf_category is parts/header.tpl (I can create Bathroomheader.tpl, Kitchensheader.tpl, etc so that relevant tpl has the relevant Title and Description tags for the page).
<?php
$vc_root_friendly = '.';
$vc_root_site = '.';
include_once("$vc_root_site/config.php");
include_once("$vc_includes_folder/IT.php");
$template_body = new HTML_Template_IT();
$template_body->loadTemplateFile("tpl_portfolio_category.html");
include_once("$vc_includes_folder/images.php");
if(!isset($_REQUEST['vf_category'])){
header("location:portfolio.php");
die();
}
//Show header
$template_header = new HTML_Template_IT();
$template_header->loadTemplateFile("parts/header.tpl",true,false);
$template_body->setVariable('header', $template_header->get());
//Show footer
$template_footer = new HTML_Template_IT();
$template_footer->loadTemplateFile("parts/footer.tpl",true,false);
$template_body->setVariable('footer', $template_footer->get());
$template_body->setVariable("image_category", $_REQUEST['vf_category']);
//Select photos for this category
etc.
Complicating things there is another page referenced in the code above:
tpl_portfolio_category.html
And this page too has its own header.tpl include:
<? include_once 'parts/header.tpl'; ?>
{header}
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="main"><h1><span class="firstLetter">{image_category}</span></h1>
<p>
</p>
<table height="89" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="7"> </td>
</tr>
<!-- BEGIN block_thumb -->
<tr>
<td width='180' height="120" background="./images/thumb-bg.gif"> <div
align="center">{thumb1}</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb2}
</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb3}
</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb4}
</div></td>
</tr>
<tr valign="bottom">
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
</tr>
<!-- END block_thumb -->
</table>
<br>
<img src="images/spacer.gif"></td>
</tr>
</table>
{footer}
Any guidance would be appreciated! I'm just trying to get parts/header.tpl to change to parts/Bathroomheader.tpl or parts/Kitchenheader.tpl based on the vf_category pulled from the database. But it's driving me nuts.
Thanks in advance,
Gary
there are a few ways to do this, but in order to minimize the number of files you're changing, I suggest that you:
a) Pull the variable from the database and assign it to smarty, on your first php file, for both the header and body:
//Assuming you have retrieved $vf_category from your database;
$template_header->setVariable('vf_category', $vf_category);
$template_body->setVariable('vf_category', $vf_category);
b) Edit your file header.tpl and append the following code at the top:
{if 'vf_category' == 'some_value'}
{include file="parts/Kitchenheader.tpl"};
{elseif 'vf_category' == 'other_value'}
{include file="parts/Bathroomheader.tpl"};
{else}
//the rest of the header.tpl code goes here
{/if}

Categories