Static page blogger template - templates

I am trying to create an issue blogger and have problems printing the contents of a static page. I want to show the contents inside a div if a page of static type, I tried the way
<b: if cond = 'data: blog.pageType == & quot; static_page & quot;'>
           <div class = 'row page' itemscope = 'itemscope'>
             <! - Blog Post Content Column ->
             <div class = 'col-LG-8 col-lg-offset-2'>
                 <! - Title ->
                 <h1> <data: blog.pageName /> </ h1>
                 <! - Preview Image ->
               <img alt = '' class = 'img-responsive' src = 'http: //placehold.it/900x300'/>
               <hr />
                 <! - Post Content ->
                 <p class = 'lead'> <data: blog.body /> </ p>
but the post content does not print and gives me an error dictionary. How I can show this content?
thank you very much

Instead of blog.body try this:
<! - Post Content ->
<p class = 'lead'>
<data: post.body />
</p>

<div id="staticpage-content">
<b:section id="staticPage" showaddelement='no'>
<b:widget id='Blog2' locked='true' title='Postagens no blog' type='Blog'>
<b:includable id='post' var='post'>
<h1><data:post.title/></h1>
<data:post.body />
</b:includable>
</b:widget>
</b:section>

Related

TypoScript: Include Right Content Column into Template Typo3 [7.6.10]

I want to use the "Right Content" Column in my Template. So i created in the backend some example content like this:
I wrote the source code of my template on my own. It looks like this:
page = PAGE
page.stylesheet = fileadmin/template_ffw/style/style.css
page.typeNum = 0
page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/template_ffw/index.html
page.10.workOnSubpart = DOCUMENT_BODY
page.10.subparts {
CONTENT < styles.content.get
ASSIDE < styles.content.getRight
MENU = HMENU
MENU.1 = TMENU
MENU.1 {
NO = 1
NO.allWrap = <div class="level1"> | </div>
}
}
page.10.marks{
LOGO = IMAGE
LOGO.altText = Logo
LOGO.file = fileadmin/template_ffw/style/ffw_logo.png
ROOTLINE = HMENU
ROOTLINE.special=rootline
ROOTLINE.special.range= 0 | -1
ROOTLINE.1=TMENU
ROOTLINE.1.NO.allWrap= | / |*| | / |*| |
}
At the index.html file i have this source code:
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body>
<!-- ###DOCUMENT_BODY### START-->
<div id="kopfzeile">
<div id="logo">###LOGO###</div>
<nav>
<!-- ###MENU### START-->
Navigationslink
<!-- ###MENU### END-->
</nav>
</div>
###SLIDER###
<div id="breadcrumb">###ROOTLINE###</div>
<div id="main">
<!-- ###CONTENT### START-->
<h1>Willkommen</h1>
<h2>Hier soll der Inhalt später stehen.</h2>
<p>An dieser Stelle soll später der Inhalt von TYPO3 eingefügt werden.</p>
<!-- ###CONTENT### END-->
<div id="asside">
<!-- ###ASSIDE### START-->
<h1>Example Heading</h1>
<!-- ###ASSIDE### END-->
</div>
</div>
<!-- ###DOCUMENT_BODY### END-->
</body>
</html>
But on the frontend the content of the Right Column is not displayed. So i have probably a bug in my typoscript. The Frontend Page looks like this:
I know this is very much source code for a question, but i searched for my Mistake this long, that i'm not shure where it is. And better to much than to less informations. I hope you can help me.
As you can see in www/vendor/typo3/cms/typo3/sysext/css_styled_content/Configuration/TypoScript/setup.txt the file StylesContent.txt from folder "Helper" is not included automatically anymore.
So I guess you must include
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:css_styled_content/Configuration/TypoScript/Helper/StylesContent.txt"> where getLeft, getRight and getBorder is definded.
Alternatively you can just add this one line after
ASSIDE < styles.content.getRight
ASSIDE.select.where = {#colPos}=2
or as I know it from that templating time ASSIDE.select.where = colPos=2
Well, but as #Thomas already recommended you should anyways switch to FLUIDTEMPLATE but getting the column not directly depends on that. I also just want to make you know that FLUID is the right thing.

How do I write html text to a file without the tags with Beautifulsoup?

This is my code. I want to write the data that I have scraped to a file. But I only want the text, not the tags, it has all the HTML tags too, I do not know how to get rid of it.
import urllib2
from bs4 import BeautifulSoup
file = open("megapy.txt", "w")
file.seek(0)
FullPage = ['New-Arrivals-2017-6', 'Big-Sales-click-here', 'Arduino-Development-boards',
'Robotics-and-Copters']
urlp1 = "http://www.arduinopak.com/Prd.aspx?Cat_Name="
URL = urlp1 + FullPage[0]
for n in FullPage:
URL = urlp1 + n
page = urllib2.urlopen(URL)
bsObj = BeautifulSoup(page, "html.parser")
descList = bsObj.findAll('div', attrs={"class": "panel-default"})
for desc in descList:
print(desc.get_text(separator=u' '))
file.write(desc.prettify("utf-8"))
file.close()
But, I keep getting this output in the text file:
<div class="panel panel-default">
<div class="panel-heading">
<h5>
2 X 8 FR4 PCB Prototype Circuit board Double Side
</h5>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-4 pro-image">
<a href="Prd_Detail.aspx?Prd_ID=20246">
<img alt="2 X 8 FR4 PCB Prototype Circuit board Double Side" class="img-thumbnail" src="http://upsats.com/Content/Product/img/Product/Thumb/PCB2x8-.jpg"/>
</a>
</div>

Cookies Drive Me CrazZy! ASP - VB Script

I'm trying to work these cookies so once the user/pass is correct it will start a cookie for the user to always show the username when logging back in (remember me feature).
While this code gave the "usernameCookie" value when I checked it at the same page, it didn't pass it to the next one. It's like it doesn't exist anymore. Of course, I used buffer=true but this is driving me crazy why it doesn't work.
<%# language="VBscript"%>
<% response.buffer = True %>
<!-- #include file = "ddsn.asp" -->
<!-- #include file = "sfuncs.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<!--Initiate form validation - in this example on the login form-->
<script type="text/javascript">
$(document).ready(function() {
$("#loginform").validate();
});
</script>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
msg = ""
If request.form ("password") <> "" Then
Set rs = Server.CreateObject("ADODB.RecordSet")
SQL = "Select id,firstName,lastName,username,password,permissions,status FROM dispatchersTBL WHERE username='" & request.form ("username") & "' and password='" & request.form ("password") & "'"
If inStr(1,SQL,";") or inStr(1,SQL,"''") OR inStr(1,LCase(SQL)," or ") Then msg = "<strong>Wrong Username or Password</strong>" End If
rs.Open SQL,SQLDSN,3,1
If NOT rs.EOF Then
Session("login") = "True"
Session("loggedUserID") = rs("id")
Session("fullName") = rs("firstName") & " " & rs("lastName")
Session("permissions") = rs("permissions")
status = rs("status")
Session.Timeout = 1440
If status = "Inactive" Then
msg = "<p><strong>Inactive User. Please contact the administrator.</strong></p>"
Else
response.cookies("usernameCookie") = rs("username")
response.cookies("passwordCookie") = rs("password")
response.cookies("usernameCookie").expires = Date() + 30
response.cookies("passwordCookie").expires = Date() + 30
response.redirect adminSiteURL & "co-worker-sms.asp"
End If
Else
msg = "<p><strong>Wrong Username or Password</strong></p>"
End if
rs.Close
Set rs = Nothing
End if
%>
<div id="admin_wrapper">
<form action="default.asp" id="login" method="post">
<%=msg%>
<!-- TEXTBOXES -->
<label>Username</label><br />
<input name="username" type="text" value="<%=request.cookies("usernameCookie")%>" class="text large required" id="username" /><br />
<div class="clearfix"> </div>
<label>Password</label><br />
<input name="password" type="password" value="<%=request.cookies("passwordCookie")%>" class="text large required" id="password" /><br />
<div class="clearfix"> </div>
<p><input name="btnLogin" type="submit" class="submit" id="btnLogin" value="LOGIN" /></p>
</form>
</div>
</body>
</html>
What am I missing?
I haven't seen your login page but your code seems ok - are you sure you do the request.cookies when you try to retrieve it ?
try make a simple page like this
<%
' put cookie
Response.Cookies("usernameCookie") = "Superman"
Response.Cookies("usernameCookie").Expires = Date() + 10
Response.Cookies("passwordCookie") = "Batman"
response.Cookies("passwordCookie").Expires = Date() + 10
%>
<% ' Print my cookie %>
<input type="text" value="<% = request.cookies("usernameCookie") %>" name="username">
<br />
<input type="text" value="<% = request.cookies("passwordCookie") %>" name="password">
After a reload page your input fields should have "superman" an "batman"

Object html representation in Django

I have written a python app which as a result creates a list of Result objects. I've written a method which makes a html representation of the object Result, showing its main attributes.
class Result():
def to_html(self):
num_of_exp = "Number of exponentials: %s"% self.number_of_exponentials
function = "Function: %s"% self.function
par_of_exp = "Parameters of exponentials: <br /> %s "% pprint.pformat(self.parameters_of_exponentials)
chunk = "Chunk: <br /> %s"% pprint.pformat(self.chunk)
backgrnd = "Background <br /> %s" % pprint.pformat(self.background)
raw_par_of_exp = "Raw parameters of exponentials: <br /> %s"% pprint.pformat(self.raw_parameters)
non_phy = "Non physical solution: %s" % pprint.pformat(self.non_physical_solution)
user_choice = "User choice: %s" % pprint.pformat(self.user_choice)
output = (function + r"<br /><br />" + num_of_exp + r"<br /><br />"+ par_of_exp + r"<br /><br />" +
backgrnd+ r"<br /><br />" + non_phy + r"<br /><br />"
)
return output
I'm using Django to make a web interface for the application.
I made a Django template:
...
<body>
{% for result in result_list %}
{{result.to_html}}
{% endfor %}
</body>
And added
return render_to_response('result_pick.html',{'result_list': rp.parsed_output_data })
where rp.parsed_output_data is a list of Result objects (the size of the list is not fixed).
The output i get completely ignores the html tags in to_html(). Html source of the output:
Function: 98.627732*2.71828182845905**(-0.016052058*t)<br /><br />Number of exponentials: 1<br ... ...
What i have to get as a final result are representations of Result objects displayed in a nice human readable format, each in its own divs and form with a next button. So when the user selects a Result he is transfered to another page where additional details are shown.
I'm looking for advices on how to do this the right and most clean way. Any comment is appreciated. Tnx
Html tags are ignored / autoescaped for safety see here and here.
The right way would be constructing html output through django templating system and not within object itself e.g.:
<body>
{% for result in result_list %}
Function: {{ result.function }}<br /><br />
Number of exponentials: {{ result.number_of_exponentials }}<br /><br />
...
{% endfor %}
</body>

src attribute of img tag inside div with a known id?

Inside a string that contains an html document that looks like :
<html>
... stuff ...
<div class="container">
<p><strong>Message title</strong></p>
<textarea class="txtarea" id="txtarea">
<table cellpadding="2">
<a href="http://somewhere.com">
<img src="http://mycdn.com/mypicId.jpg" width="280" height="280">
</a>
</table>
</textarea>
</div>
... stuff ...
</html>
, using regex, how do I get the src attribute of the img tag inside the div with class "container", knowing that there are multiple other img tags in other parts of the html ?
No need to regex, use jQuery
var src = $('.container img').eq().attr('src')
eq() allows to to specify which single element to return.
You could also use :nth-child() in the selector
Plain Javascript:
var src = document.getElementsByClassName('container')[0]
.getElementsByTagName('img')[0].src;
jQuery:
var src = $('.container img').attr('src');
JSFiddle
By the way, That HTML isn't valid as you have <img> inside <textarea> ?!