Rich text editor

Topics: Customizing Orchard
Nov 30, 2011 at 11:41 AM

Hi,

How can i take rich text editor. I want create blog with images and text. So i want rich text editor. 

 

lakmal

 

Coordinator
Dec 1, 2011 at 4:14 AM

It's already there. I don't understand the question.

Dec 1, 2011 at 4:23 AM

I have use this to handle my content

 @Html.TextAreaFor(m => m.Articles.Content, 5, 50, null)

 

But i cant insert image and i cant format text from textare. 

Coordinator
Dec 1, 2011 at 4:26 AM

Why don't you just use a body part and be done with it?

Dec 1, 2011 at 4:32 AM

i am creating module to handle article. My table has field content. I want send content to my table filed, Can i send data to my table filed using body part.

 

Coordinator
Dec 1, 2011 at 4:34 AM

How is an article different from a blog post? Why don't you create a content type by aggregating content parts? Do you have more than one property that is rich text?

Dec 1, 2011 at 5:25 AM

Hi,

Now i getting idea

Here is my article table properties

 public virtual DateTime ?    DateListed { get; set; }
        public virtual DateTime ? DatePublished { get; set; }
        public virtual int CategoryID { get; set; }
        public virtual int SponsorID { get; set; }
        public virtual string  ArticlesName { get; set; }
        public virtual bool  IsPublished { get; set; }
        public virtual string  Publisher { get; set; }
        public virtual string  Source { get; set; }
        public virtual string  Lead { get; set; }
        public virtual DateTime ? StartDate { get; set; }
        public virtual DateTime ? EndDate { get; set; }
        public virtual bool IsTop { get; set; }
        public virtual bool IsArchive { get; set; }
        public virtual bool  UseImage { get; set; }
        public virtual bool MembersOnly { get; set; }
        public virtual bool UseHeaders { get; set; }
        public virtual string  Content { get; set; }

According to ur explanation i can create this module from following parts

 

CategoryPart

Blogart

PublishLaterPart a

Artcilepart to handle other data

 

Am i correct?

 

lakmal

 

Coordinator
Dec 1, 2011 at 7:56 AM

Both dates can be handled by CommonPart, category can be handled by taxonomies or lists. Name looks like a title, which is in routable. IsPublished is handled by the draftable flag on the type. Publisher looks like the author, available from Common. Content is BodyPart. The rest may be a custom part, or fields.

Dec 1, 2011 at 1:59 PM

Hi,

How can i display routerpart title to user front end

Model.Title is not working

 

Coordinator
Dec 1, 2011 at 3:40 PM

From what template? Did you try to find it from the Model tab of shape tracing?

Dec 1, 2011 at 3:45 PM

I have done this way

var Articless = _ArticlesService.Get().Select(b => Services.ContentManager.BuildDisplay(b, "Summary"));

            var list = Shape.List();
            list.AddRange(Articless);

            dynamic viewModel = Shape.ViewModel()
                .ContentItems(list);

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            return View((object)viewModel);
@{
    Model.ContentItems.Classes.Add("content-items");
    Model.ContentItems.Classes.Add("Articless");
}
@using (Html.BeginFormAntiForgeryPost())
{ 
    @Html.ValidationSummary()
    <div class="manage">@Html.ActionLink(T("Add a new Articles").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
}
@Display(Model.ContentItems)
@if (Model.ContentItems.Items.Count < 1) {
<p>@T("No Articless found.")</p>

 

I want customize this template, eg. Display part of body and change data positions 

 

Coordinator
Dec 1, 2011 at 6:23 PM

I'm sorry, this doesn't answer my questions.

Dec 2, 2011 at 2:56 AM

When i goto this link   http://localhost:30320/OrchardLocal/Admin/eProp.Articles  my shape tracing icon disapear, why that

 

Coordinator
Dec 2, 2011 at 4:00 AM

Shape tracing is not available from the admin.

From any template, Model represents the shape that it represents. In your case that's the List shape. The only thing you have on there is ContentItems. Is it from that template that you are trying to display the title? It's not clear.

Dec 2, 2011 at 5:24 AM

Yes from contentitem i want display and format title

Coordinator
Dec 2, 2011 at 5:50 AM

I'm really not sure what you mean by "from content item". The only template that you showed here is for the list shape. Each content item in the list will be displayed by several templates (typically one for the content item defining local zones, and one per part, that will get rendered in one of the zones according to placement). If you mean from one of the templates for one of the parts of one of the content items in the list (which is really not clear), and if the part driver exposed the content item on the shape (which most drivers, but not all do), then @Model.ContentItem.RoutePart.Title should give you what you want.

Dec 2, 2011 at 9:49 AM

Hi,

I have done this way

@{
    Model.ContentItems.Classes.Add("content-items");
    Model.ContentItems.Classes.Add("Articless");
}
@using (Html.BeginFormAntiForgeryPost())
{ 
    @Html.ValidationSummary()
    <div class="manage">@Html.ActionLink(T("Add a new Articles").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
    foreach (var ContentItem in Model.ContentItems)
    { 
        <h1>Article Name</h1>
    <h1>@ContentItem.RoutePart.Title</h1>
    }
}
 

I have 4 article. this one  <h1>Article Name</h1> display 4 times, But title didnt display

Something wrong there?

 

lakmal


 

Coordinator
Dec 2, 2011 at 8:21 PM

Attach a debugger, you'll probably see what's wrong. You articles do have the route part, right?

Dec 5, 2011 at 10:10 AM

I have debug code

Here is my code

@using Orchard.DisplayManagement.Shapes;
@{
    var list = Model.ContentItems;
    var items = list.Items;
    var count = items.Count;
    var listTag = Tag(list, "ul");
    listTag.AddCssClass("content-items");
    listTag.AddCssClass("blog-posts");
    var index = 0;
}
@listTag.StartElement
    @foreach (var item in items)
    {
        var itemTag = Tag(item, "li");
        if (index == 0)
        {
            ShapeMetadata metadata = item.Metadata;
            string alternate = metadata.Type + "_" +
                    metadata.DisplayType + "__" +
                    item.ContentItem.ContentType +
                    "_First";
            metadata.OnDisplaying(ctx =>
            {
                metadata.Alternates.Add(alternate);
            });
            itemTag.AddCssClass("first");
        }
        else if (index == count - 1)
        {
            itemTag.AddCssClass("last");
        }
        @itemTag.StartElement  
             
                
        @Display(item)
        @itemTag.EndElement
   ++index;
    }
@listTag.EndElement

 

When i add item to quick watch  i can see property called __target.Title   it has title value too

 

Then i add this code

 

@item.__target.Title   but nothing display

 

Coordinator
Dec 5, 2011 at 9:10 PM

Yes, __target is private, that can't work.

What do you see in the debugger when you look at item.RoutePart.Title? What about item.RoutePart?

Dec 6, 2011 at 4:36 AM

If i add item.RoutePart.Title quickwatch i can see 

_behavior
claySharp
DynamicView

But item.RoutePart.Title  display empty. This is my conroler code

 var Articless = _ArticlesService.Get().Select(b => Services.ContentManager.BuildDisplay(b, "Summary"));
          
            var list = Shape.List();
            list.AddRange(Articless);

            dynamic viewModel = Shape.ViewModel()
                .ContentItems(list);

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            return View((object)viewModel);

And this is my article service code

 

public IEnumerable<ArticlesPart> Get(VersionOptions versionOptions)
        {
            return _contentManager.Query<ArticlesPart, ArticlesPartRecord>(versionOptions)
                .Join<RoutePartRecord>()
                .OrderBy(br => br.Title)
                .List();
        }

 

Is there any mistake in this code?

 

lakmal

Coordinator
Dec 6, 2011 at 4:56 AM

What about item.RoutePart?

Dec 6, 2011 at 5:15 AM

When i add item.RoutePart to quick watch it also display 

_behavior
claySharp
DynamicView

 

There is no Title property

 

lakmal

Coordinator
Dec 6, 2011 at 5:18 AM

You need to dig a little deeper than that. Any information you can extract from item itself?

Dec 9, 2011 at 7:21 AM

 

OK, I have fix that. I use following 

item.Title

and for Id

item.ContentItem.Id

Dec 10, 2011 at 1:57 PM

Hi,

I have another problem. How can i take body text?

I have tried this  item.body

 

But it didnt work

 

lakmal

Coordinator
Dec 11, 2011 at 12:24 AM

Did you look in shape tracin'g model tab? Should be something like item.BodyPart.Text

Dec 11, 2011 at 3:47 AM

Hi,

This is my url

http://localhost:30320/OrchardLocal/eProp.Articles/articles/item/93

 

This is not admin module. But shape tracing is disable for this,Why that?

 

lakmal

Coordinator
Dec 11, 2011 at 4:17 AM

I don't know. Is the feature enabled?

Dec 11, 2011 at 5:24 AM

Yes feature is enable. My home page can do shape tracing

Coordinator
Dec 11, 2011 at 5:39 AM

I don't know. Maybe you have a javascript error happening before it gets a chance to build itself. Look at your javascript console.