WeStandWithUkraine

2 Posts
Garrett
8 years ago
Topic

Hello I am new to Seblod.

Can someone tell me if Seblod can create an article and create a menu item, then assign that article to that menu? I am looking for ways to automate the creation of content on my site. The idea would be to take 15 steps of creating content down to 3 or something.

Thanks

Get a VIP membership
8 years ago
0
Level 1

Hi Garrett, try NoNumber AddtoMenu Plugin for that need. Hope that helps!

233 Posts
pepperstreet
8 years ago
0
Level 1

FYI - I have created a related topic and tracker item over here... 

http://www.seblod.com/community/forums/lists-search-types/automatic-menu-list-with-categories-plus-articles#post13385

233 Posts
pepperstreet
8 years ago
0
Level 1

BTW, are you talking of frontend submissions? Do you need a custom ordering of articles, or just one of the available defaults? i.e. alphabetical, by dates, backend manager order etc.

1279 Posts
Bucklash
6 years ago
0
Level 1

Hi folks

You can do this: Create Article, create menu item which points to this article

1
you need to have the field AfterStore

2
You need to add this field to your article form

3
You need to get the id of the article you have just created and saved

$artId = $config['pk']; // a search through the seblod forums will get you this answer
	

4
You need to add the code that creates a menu item (You will need to know specific menu item info like "path", "link" etc - tip: create a menu item that matches the one you want to create and use those db values).

 

How you want to point to your article will dictate how to construct the link. In this example I have the id of the article just created added to the url.
For the search and list type, I have the art_id field in the search form, and for the live value: 'url - variable'. Select this and then under 'live value' you can click configure. Set 'type' to 'Integer', and 'variable' to 'id'. That pulls the id value from the url. There are many ways of doing achieving the same result...
// Create the menu item
$menuTable = JTableNested::getInstance('Menu');
// assign the values
$menuData = array(
    // Uncomment as necessary
    // 'id' = '; // Automatic
    'menutype' => $menuType, // Required
    'title' => $menuTitle, // Required
    'alias' => $menuAlias, // I used this: 'alias' => JFilterOutput::stringURLSafe($menuTitle);
    'note' => $note, 
    etc.....
    'link' => 'index.php?option=com_cck&view=list&search=my_user_group_search_type&task=search&id=' . $artId;
    // make sure 'lft' and 'rgt' are commented out
    // 'lft' => ,
    // 'rgt' => ,
    // 'home' => 0,
    'language' => '*', // Required
    'client_id' => 0 // Required
);
// this menu item is at the root so the parent id needs to be 1, refer to db
$parentId = 1;// or whatever you need it to be
$menuTable->setLocation($parentId, 'last-child');
// save is the shortcut method for bind, check and store
if (!$menuTable->save($menuData))
{
  $this->setError($menuTable->getError());
  return false;
}
// Menu Item created

 

As a bonus example of creating something else with AfterStore....

//
// Create User Group
//
// ($newUG can be changed to whatever you want ie $potatoSniffer)
// ($addUG can be changed to whatever you want ie $dangerMouseRules)
// 
$newUG = new JCckContent( 
    array('joomla_user_group') 
); 
$addUG = $newUG->create(
    'my_content_type_name_based_on_user_group',
    array(
        // data to go in the standard Joomla UG fields
        'title'=> $title,
        'parent_id'=> $ugParent
    ),
    array(
        // data to go in the Seblod table ie #__cck_store_form_my_content_type_name_based_on_user_group
        'color' => $ugColor;
        'funky' => $hellYeah
    )
);
// Usergroup created
<br>

I was able to create multiple menu items...

Create Menu Item Dynamically

Insert Multiple Rows in table with lft and rgt columns

Bucklash

Get a Book for SEBLOD