Get Element by element name?

29 views
Skip to first unread message

suzan...@gmail.com

unread,
Jan 3, 2018, 5:13:51 PM1/3/18
to SmartAPI
Is it possible to get the element of page by its name? I was browsing through the SmartAPI library and it doesn't look like there's any methods available for it. Please advise.

suzan...@gmail.com

unread,
Jan 3, 2018, 5:43:58 PM1/3/18
to SmartAPI
If not - is it possible to get a full list of all elements in a specific page?

Jonas Jacobi

unread,
Jan 4, 2018, 9:28:41 AM1/4/18
to smar...@googlegroups.com

You can access elements by name like this:

IPage myPage = …;

IPageElement element = myPage[“myElementName”];

 

If you know the element type and want to access type specific properties/methods, you can just cast it, e.g.

ITextHtml element = (ITextHtml)myPage[“myHtmlTextElement”];

 

Dr. Jonas Jacobi

Technical Lead


cid:1CED22B6-B0AD-42DB-B967-5CC408FF6360@fritz.box



Mobile Lösungen, Apps und das Internet der Dinge


Ehnernstr. 157

26121 Oldenburg, Germany

 

jonas....@erminas.de

http://www.erminas.de


Registergericht: Amtsgericht Oldenburg, HRB 209480
Geschäftsführer: Hilmar Bunjes

--
More information about SmartAPI: http://www.smartapi.de
---
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "SmartAPI" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an smartapi+u...@googlegroups.com.
Wenn Sie in dieser Gruppe einen Beitrag posten möchten, senden Sie eine E-Mail an smar...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

Jonas Jacobi

unread,
Jan 4, 2018, 9:35:17 AM1/4/18
to smar...@googlegroups.com

Additionally, if you want to get lists of alle elements, you can also access them through

IPage.ContentElements and IPage.LinkElements

 

Dr. Jonas Jacobi

Technical Lead


cid:1CED22B6-B0AD-42DB-B967-5CC408FF6360@fritz.box



Mobile Lösungen, Apps und das Internet der Dinge


Ehnernstr. 157

26121 Oldenburg, Germany

 

jonas....@erminas.de

http://www.erminas.de


Registergericht: Amtsgericht Oldenburg, HRB 209480
Geschäftsführer: Hilmar Bunjes

 

From: smar...@googlegroups.com [mailto:smar...@googlegroups.com] On Behalf Of suzan...@gmail.com
Sent: Mittwoch, 3. Januar 2018 23:44
To: SmartAPI <smar...@googlegroups.com>
Subject: [SmartAPI] Re: Get Element by element name?

 

If not - is it possible to get a full list of all elements in a specific page?



On Wednesday, January 3, 2018 at 3:13:51 PM UTC-7, suzan...@gmail.com wrote:

Is it possible to get the element of page by its name? I was browsing through the SmartAPI library and it doesn't look like there's any methods available for it. Please advise.

--

suzan...@gmail.com

unread,
Jan 4, 2018, 4:32:22 PM1/4/18
to SmartAPI
Thank you Jonas, this works perfectly!

Can you please advice how what I am supposed to pass in as a the parameter for the page.Create method? How would I pass through the IContentClass? I tried passing through the template guid but it did not work.

Regards,

Suzanne

Jonas Jacobi

unread,
Jan 5, 2018, 4:17:28 AM1/5/18
to smar...@googlegroups.com

Hi Suzanne,

 

you need to fetch the content class object and user that as parameter.

E.g.

IProject project = …;

IContentClass cc1 = Project.ContentClasses.GetByName(“MyCC1”);

IContentClass cc2 = Project.ContentClasses.GetByGuid(…);

 

IPage newPage1 = project.Pages.Create(cc1);

IPage newPage2 = project.Pages.Create(cc2, “New Headline”);

 

If you want to, you can also create and connect a page with a single command: project.Pages.CreateAndConnect :

http://www.smartapi.de/smartapi_doc/a00156.html

 

Cheers

Jonas

suzan...@gmail.com

unread,
Jan 11, 2018, 10:20:41 AM1/11/18
to SmartAPI
Thanks Jonas.

What would be the best way to return the page guid for the newly created page?

Jonas Jacobi

unread,
Jan 11, 2018, 10:22:43 AM1/11/18
to smar...@googlegroups.com

IPage newPage1 = project.Pages.Create(cc1);

newPage1.Guid

suzan...@gmail.com

unread,
Jan 11, 2018, 3:52:08 PM1/11/18
to SmartAPI
Thank you Jonas!

Just wondering if its possible to get a list of all the pages in a lst_navigation?
Reply all
Reply to author
Forward
0 new messages