I'm working on a modification from a theme in the open source project "gallery2".
Here is the code that I am looking at:
For anyone familiar with it, its in the SearchShowAll.tpl file in the search module in the modules section of the download.
<ul class="giInfo">
{foreach from=$result.fields item=field }
<li>
<span class="ResultKey">{$field.key}:</span>
<span class="ResultData">{$field.value|default:" "|markup}</span>
</li>
{/foreach}
</ul>
It is a smarty foreach loop and it grabs this data
Title: BB 08 PR 6-340
Summary:
Keywords: A Hillbilly Cat; Gavin Jordan; Margo Hazell
Description:
Owner: Gallery Administrator
However, I just want it to get the Title: and display it, not any of the other stuff. I am unsure of what the array looks like and how to get a specific value from it in smarty format and also in the case of this gallery.
I used section tags to figure this out. I was referencing the array value wrong as well. Here is how I got it to work.
{section name=field loop=$result.fields max=1}
<li>
<span class="ResultData">{$result.fields[field].value|default:" "|markup}</span>
</li>
{/section}
Related
I have a PHP function which contains the footer applied to each of my web pages. For the majority of the pages it is displayed as it should. But on some pages it isn't and it seems to be caused by what I can only describe as 'phantom elements' as they aren't within my HTML/PHP code but are shown in Elements of the browser Development Tools. See the below screenshot of the code:
Screenshot of code issue
Basically it adds an empty anchor element which contains no text but CSS is applied to it giving it the padding of the other tags, which ultimately pushes all of the other list and anchor elements to the right of the empty anchor.
The PHP function is:
function enterFooter (){
$pageFoot = <<<FOOT
<footer class="web-foot">
<div class="link-container">
<ul>
<li>
Homepage
</li>
<li>
Sitemap
</li>
<li>
Company
</li>
<li>
Home
</li>
</ul>
</div>
</footer>
FOOT;
echo $pageFooter;
Any ideas what could be causing this problem?
I'm having a strange problem with a Wordpress site I built recently, wherein when users visit one of the website's pages via search engine (typically Google), a bit of strange markup is generated inside the footer element. That markup is an unordered list of dates linking to non-existent archive pages, and an unordered list of categories linking to non-existent category pages.
The strange thing here is that there is no code in the theme that would generate this markup, and even more peculiarly, the categories in the unordered list don't exist in the site's database. My first thought was that this could be the result of a possible malware infection, but since the links don't direct the user offsite, that seems unlikely. It would also be strange for the malware to generate problems only when the site is accessed via search engine.
I've been scouring the Internet looking for an example of this occurring, but have yet to find anything, and though I've been working in WP dev for over a year now, this is my first time encountering such a problem. So, my question is this: have any of you encountered something like this before, and if so, do you have any ideas on what could be the problem source, and/or do you have recommendations about how to go about debugging the issue?
NOTE: I have already hidden the markup using CSS for a user-facing solution, so I'm looking for an answer to help me address the problem more sustainably; i.e., finding a way to eliminate the markup in question.
Thanks!!
<ul>
<li><a href='http:/2015/10/'>October 2015</a></li>
<li><a href='http:/2015/09/'>September 2015</a></li>
<li><a href='http:/2015/07/'>July 2015</a></li>
<li><a href='http:/2015/06/'>June 2015</a></li>
</ul>
<ul>
<li class="categories">Categories<ul>
<li class="cat-item cat-item-14"><a href="/category/articlesorder/" >articles,order</a>
</li>
<li class="cat-item cat-item-13"><a href="/category/articlesus/" >articles,us</a>
</li>
<li class="cat-item cat-item-11"><a href="/category/businesswriting/" >business,writing</a>
</li>
<li class="cat-item cat-item-16"><a href="/category/englishorder/" >english,order</a>
</li>
<li class="cat-item cat-item-17"><a href="/category/serviceterm/" >service,term</a>
</li>
<li class="cat-item cat-item-12"><a href="/category/shoolbuy/" >shool,buy</a>
</li>
<li class="cat-item cat-item-18"><a href="/category/studybusiness/" >study,business</a>
</li>
<li class="cat-item cat-item-15"><a href="/category/studypapers/" >study,papers</a>
</li>
</ul></li>
</ul>
Try to change the theme and see if it is the source of this and then disable every plugin and enable one after one to see which of them generates the code.
If this just happens when someones comes from a search engine it is called cloaking.
Please check also the code in your .htaccess and all core files.
You can use Wordfence to scan the files for changes https://de.wordpress.org/plugins/wordfence/
I am trying to figure out a way of organizing a php multidimensional array with the different pages and organized by parent and child. I was considering just using a flat file rather than a MySQL DB.
Would it be possible to organize it so that I can include a php file near the top of the content section of a site that would dynamically print the current page and its parent pages in a similar way like this?
Home >> About >> Meet the Team
Thank you!
You could always store the name of the current page on a variable at the top of your file and then do something like this:
[php]
$page = "About";
$descrip = "About the Team";
[html]
<ul>
<li>Home /</li>
<li> <? echo $page; ?> / </li>
<li> <? echo $descrip; ?> / </li>
</ul>
A quick solution but effective
I have this smarty template, I need to call a function from my file.
Everything works fine, php recognizes the parameters, but not the values of the smarty variables.
Code:
{insert name=file_details value=a assign=fd fid=$m[i].FID}
<ul class='list'>
{section name=x loop=$fd}
{insert name=gfs assign=afs a=$fd[x]}
<li><a href="{$baseurl}/files/{$fd[x].FID|md5}{$fd[x].s}/{$fd[x].fname}" target="_blank">
{$fd[x].fname} <b>[{$afs}]</b>
</a></li>
{/section}
</ul>
Meaning.
the first insert retrieves some file information from my database, using as parameter $m[i].FID everything works fine, when I tell him for example {$fd[x].fname} it displays the name of the file, but when I tell him {insert name=gfs assign=afs a=$fd[x]} and make a var_dump(a) in the function insert_gfs all the values appear as null.
Any help would be great, I don't know what i'm missing
Arrays are writen as $m.i in Smarty. Not $m[i].
If you replace all your array notations like this, it should work.
{insert name=file_details value=a assign=fd fid=$m.i.FID}
<ul class='list'>
{section name=x loop=$fd}
{insert name=gfs assign=afs a=$fd.x}
<li><a href="{$baseurl}/files/{$fd.x.FID|md5}{$fd.x.s}/{$fd.x.fname}" target="_blank">
{$fd.x.fname} <b>[{$afs}]</b>
</a></li>
{/section}
</ul>
While I'm using this site quite often as a resource for jQuery related problems I can't seem to find an answer this time. So here is my first post.
During daytime at work I'm developing an informationsystem for generating MS Word documents. One of the modules I'm developing is for defining a default chapterselection for the table of contents and selecting texts by the given chapters. A user can submit new chapters and if necessary, add them as childchapter to a parent, flag them as 'adopt in TOC' and link a default text (from another module) to the chapter.
My chapterlist is retreived recursively from a MySQL table and could look something like this:
<ul class="sortableChapterlist">
<li>1</li>
<li>2
<ul class="sortableChapterlist">
<li>2.1</li>
<li>2.2</li>
<li>2.3
<ul class="sortableChapterlist">
<li>2.3.1</li>
<li>2.3.2</li>
</ul>
</li>
</ul>
</li>
</ul>
In FireFox the code works like a charm but IE (7) doesn't seem to like it that much. I'm only able to correctly drag arround the mainchapters. When attempting to drag a subchapter, no matter it's level, the correspondending mainchapter lifts up with some child, never all.
This is the jQuery code I'm using to accomplish the task:
$(function(){
$(".sortableChapterlist").sortable({
opacity: 0.7,
helper: 'clone',
cursor: 'move'
});
$(".sortableChapterlist").selectable();
$(".sortableChapterlist").disableSelection();
});
Does anybody have some ideas about this? I'm guessing IE kinda falls over the multiple class reference "chapter_list" in combination with jQuery trying to handle the draggable/sortable.
I believe you could fix this by only applying the sortable to the root <ul> element, rather than all of them in the tree. This works in all browsers I have tested, but unfortunately leads to a slightly less smooth experience as the position at which the item will be inserted after dragging "jumps around" quite a bit.
Essentially this would look like this:
<ul id="sortableNestedList" class="sortableChapterlist">
<li>1</li>
<li>2
<ul class="sortableChapterlist">
<li>2.1</li>
<li>2.2</li>
<li>2.3
<ul class="sortableChapterlist">
<li>2.3.1</li>
<li>2.3.2</li>
</ul>
</li>
</ul>
</li>
</ul>
$("#sortableNestedList").sortable({ ... });
This is a long shot, but try to replace the underscores with something else, e.g. a hyphen. Underscores used to cause problems in some browsers.
Mozilla Developer Center: Underscores in class and ID names.