In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today Xiaobian to share with you the php CMS page design and layout of the relevant knowledge points, detailed content, clear logic, I believe most people are still too familiar with this knowledge, so share this article for your reference, I hope you have read this article after harvest, let's learn about it together.
Field means field, and when we present a piece of data, we always show specific fields, sometimes a piece of data, sometimes a loop.
A piece of data is easy to process, we prepare the data, and then replace the relevant [field] label. When looping output, you only need to call the method that displays a piece of data.
The label format for a Field looks something like this: [field:PostTime length=10 dateFormat="y-MM-dd HH:mm"/] As you can see, a Field has some attributes of its own, just like a Label.
When we display Field, it is sometimes impossible to display it exactly according to the field name of the database, such as the PostTime field of the publication time. We may need to display it as "how long ago", such as "just now","5 minutes ago", etc., and then we need to call a method (Render) to handle it. So the Field class needs an exposed method member and a Value field to store the initial value.
For code consistency, we call the Render method uniformly, but God knows what the Render method does. We can design a FieldBase that returns the initial value Value by default.
The general design of the class looks like this:
public class FieldBase
{
public string Name {get;set;}
public string Value {get;set;}
public string Html {get;set;}//html The full tag used to store Field
public virtual string Render()
{
return Value;
}
}
So, does this mean we have to implement a concrete Field class whenever we have slightly inconsistent Render? Wouldn't that be the legendary explosion? Also, we need to think about how to instantiate these different Render subclasses with simple field tags. Obviously there are problems with inherited design.
So, we have to change Render down:
//…
public event Func Render;
public virtual string GetRender()
{
//if(SetValue!= null)
// SetValue(this,RowData)
if(Render!= null)
return Render (this,Value);//This indicates an ordering problem: before calling GetRender, you must assign a Field.Value value if you want it, as we'll see later.
else
return Value;
}
//public Object RowData {get;set;}
public Func SetValue;
//…
Yes, we just added an event and changed the name, so that we wanted to publish a custom method externally, but implement the invocation mechanism internally. And GetRender is still rewritable, for example, some very special Field labels may need to rewrite FieldBase.
GetRender is written very simply, but the actual usage is complicated. Have you noticed that we ignore the Parameters of field (those length formats and the like)? In fact, the call situation is similar to the Parameters of Label.
The above is "php cms page design and layout example analysis" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.